NEW
Font size
WorksheetsThe Ultimate C++ Quiz
Total questions: 7
Worksheet time: 4mins
What will print out?
int x, y;
x = y;
x = 1;
if (x>y)
{
y = x;
y = 1;
} else
{
x = 2;
}
cout<<x<<endl<<y;
1
2
0
2
1
0
2
1
What will print out?
int x, y;
x = 1;
if (x == 0)
{
x = 0;
y = 1;
} else
{
y = x*x;
}
cout<<y;
1
2
3
4
What will print out?
int x, y, z;
x = 1;
y = 5;
z = x+y-1;
while (true)
{
if (x<z)
{
x = z;
z = x;
y = x;
x = y;
break;
} else
{
x = 1;
y = x;
z = y;
}
}
cout<<x<<endl<<y<<endl<<z;
1
5
5
5
5
5
1
6
6
1
1
1
What will print out?
for(int x=-3;x<=0;x++)
{
cout<<x-1<<endl;
}
-3
-2
-1
0
-4
-3
-2
-1
0
-4
-3
-2
-1
-2
-1
0
What will print out?
bool a = true;
while (a == true)
{
cout<<"Hello World!";
a = false;
}
Hello World!
Nothing will be printed out on the screen
What will print out?
bool a = true;
while (a == true)
{
a = false;
cout<<"Hello World!";
}
Hello World!
Nothing will be printed out on the screen
What will print out?
while (true)
{
break;
cout<<"Hello World!";
}
Hello World!
Nothing will be printed out on the screen
