NEW
Font size
WorksheetsC++ QUIZ
Total questions: 14
Worksheet time: 5mins
Who is the creator of C++?
Dennis Ritchie
James Gosling
Bjarne Stroustrup
Guido van Rossum
In which year was C++ created?
1980✅
1983
1972
1991
Which of the following is a correct C++ comment?
This is a comment
<-- This is a comment -->
# This is a comment
/* This is a comment */
What is the correct syntax to print "Hello, World!" in C++?
print("Hello, World!");
Console.WriteLine("Hello, World!");
cout << "Hello, World!";
printf("Hello, World!");
What will be the output of this if-else statement?
int x = 10;
if (x > 10)
cout << "Greater";
else
cout << "Smaller";
Smaller
Greater
Error
No output
How many times will this loop execute?
for(int i = 0; i < 5; i++) {
cout << i << " ";
}
Infinite
6 times
4 times
5 times
What is the output of this loop?
int i = 1;
while (i < 4) {
cout << i << " ";
i++;
}
1 2 3
0 1 2
1 2 3 4
Infinite loop
Which of the following is NOT a C++ loop?
while
for
do-while
repeat
How can you terminate a loop in C++?
continue;
break;
exit;
terminate;
What is the output of this code?
int x = 5;
if (x == 5) {
cout << "Equal";
} else {
cout << "Not Equal";
}
No Output
Error
Not Equal
Equal
What is the purpose of the else statement in C++?
Skips the next statement
Loops infinitely
Runs when the if condition is true
Runs when the if condition is false
Which loop executes at least once even if the condition is false?
for loop
while loop
infinite loop
do-while loop
What does the continue statement do inside a loop?
Ends the loop execution
Skips the rest of the code in the current iteration and moves to the next iteration
Exits the program
Restarts the loop from the beginning
What is the correct syntax for an if-else statement in C++?
if {x == 5} then {cout << "Yes";} else {cout << "No";}
if x == 5
cout << "Yes";
else
cout << "No";
if (x == 5)
cout << "Yes";
else
cout << "No";
if x = 5 { cout << "Yes"; } else { cout << "No"; }
