Which of the following is the correct extension of C++ files?
A
.cp B
.c++ C
.cpp D
.c
Analysis & Theory
C++ source files commonly use the `.cpp` extension.
Who developed the C++ programming language?
A
Dennis Ritchie B
James Gosling C
Bjarne Stroustrup D
Guido van Rossum
Analysis & Theory
Bjarne Stroustrup developed C++ at Bell Labs in the early 1980s.
Which of the following is used to output data in C++?
A
print B
cout C
output D
write
Analysis & Theory
`cout` is used with the insertion operator (`<<`) to output data in C++.
Which header file is required to use `cout` and `cin`?
A
<iostream> B
<stdio.h> C
<stdlib.h> D
<conio.h>
Analysis & Theory
`<iostream>` defines the standard input and output stream objects `cin` and `cout`.
What is the correct way to write the main function in C++?
A
void main() B
int main() C
main() D
function main()
Analysis & Theory
`int main()` is the standard signature for the entry point of a C++ program.
Which of the following symbols is used to insert comments in C++?
A
// comment B
# comment C
/* comment D
-- comment
Analysis & Theory
`//` is used for single-line comments in C++. You can also use `/* */` for multi-line.
Which operator is used for input in C++?
A
>> B
<< C
<> D
**
Analysis & Theory
`>>` is the extraction operator used with `cin` for input.
What will be the output of `cout << 2 + 3;`?
A
5 B
2 + 3 C
23 D
Error
Analysis & Theory
The expression `2 + 3` is evaluated to 5, then printed by `cout`.
Which of the following is a correct variable declaration in C++?
A
int 1x; B
int x; C
float x y; D
int; x = 10;
Analysis & Theory
`int x;` correctly declares an integer variable. Variable names cannot start with numbers.
Which keyword is used to define a constant in C++?
A
const B
define C
fixed D
immutable
Analysis & Theory
`const` is used to declare constants in C++.