Font size
WorksheetsQuiz #1
Total questions: 16
Worksheet time: 8mins
Who invented C++?
Dennis Ritchie
James Gosling
Bjarne Stroustrup
Guido van Rossum
Select the valid IDENTIFIERS
hello
_
1_2_3
hello123
Int
Which of the following is a correct way to declare an integer variable in C++?
int 1num;
integer num;
int num;
int-number;
What is the output of the given code?
4
5
6
Compilation Error
Which of the following is not a valid C++ data type?
string
bool
integer
double
Which loop will always execute its body at least once, regardless of the condition?
for loop
do-while loop
while loop
None of the above
What is the purpose of the break statement in C++?
To terminate the current loop or switch statement
To terminate the program
To skip the current iteration
To restart the loop
What will be the output of the given code?
1 1 1 1 1
1 2 3 4 5
5 4 3 2 1
Infinite loop
What is the result of the following operation: 5 & 3?
1
3
5
7
What is the result of 4 ^ 5?
2
0
9
1
What will be the output of the given code snippet?
x is between 3 and 10
No output
Compilation error
x is less than 3
In C++, how do you write an if condition that checks if a variable x is either 5 or 10?
if (x == 5 && x == 10)
if (x == 5 || x == 10)
if (x = 5 || x = 10)
if (x == 5 and x == 10)
It is possible to nest if statements within other if statements in C++.
True
False
The continue statement can be used in if conditions but cannot be used in loops.
True
False
The ternary operator ? : is also known as the (a) operator and is used for shorthand conditional expressions.
Want more QUIZs in up-coming sessions?
Yes
No
