WorksheetsC++ Quiz
Total questions: 20
Worksheet time: 18mins
What is the output of this code?
int x = 8;
// x = 3;
cout<<x<<endl;
3
8
error
x
What is the type of the temp variable?
var temp = 14.55;
Double
Boolean
Integer
String
What is the alternative for x = x + 5?
x += 5;
x -= 4;
x = y + 5;
x=+5
What is void?
A statement that returns a value
A statement that doesn't return a value
A function that return a value
A function that doesn't return a value
iostream
Displays output from the screen and input from the keyboard
Has all the math equations
Counts the time
Checks if the code has a function
Switch Statement
Is a statement with a set of conditions called cases
Is a case
Is a condition with no cases
Is a boolean statement
Loops in C Language are implemented using.?
While
For
Do While
All the above
What is the way to suddenly come out of or Quit any Loop in C Language.?
continue; statement
break; statement
leave; statement
quit; statement
What is the only function that all C++ programs must contain?
main ()
void ()
system ()
start ()
Which operators are used in C++?
==
+=
**
++
AND operator in C++ is written as:
&&
&
||
AND
Where is the mistake?
% must be replaced with /
= must be replaced with ==
3 must be replaced with 2
There is no mistake
What are the mistakes in this code?
x must be <=10 instead of x<100
The function is log(x) not log10(x)
float sum must be used instead of int sum
cin>>x
is not needed
Math library is not needed
Which of the following loops goes to infinity?
for (int i=0 ; ; )
for (int i=0 ; ; i=∞)
for (int i=0 ; i<=1000000000000000000 ; i++)
for (int i=0 ; ; i++)
Which loop executes the statements at least one time before evaluating the expression?
do-while loop
for loop
while loop
none of the above
What will be the output of this code?
for (int n=10; n>0; n- -)
{
if (n==4) continue;
cout<<n<<endl;
}
10,9,8,7,6,4,3,2,1
10,9,8,7,6,5,4,3,2,1
10,9,8,7,6,5,3,2,1
10,9,8,7,6,5,4,3,2,1,0
((4==4) && (3>6)) returns:
True
False
cout<<floor(12.5)<<endl;
prints:
12
13
12.5
None of the above
scope of variable (age) is:
a local variable
a global variable
integer
18
C++ is a
high-level language
low-level language
