How many times will the following code print?
Question: How many times will the following code print “T4Tutorials”?
int count = 0+1;
while ( count < 4)
{ cout << “T4Tutorials” << endl;
count++; }
(A). 0
(B). 1
(C). 3
(D). 4
(E). None of these
Answer of Multiple Choice Question: (C). 3
Question: How many times will the following code print “Hello World”?
int count = 2;
while ( count <= 4 – 1)
{ cout << “Hello World” << endl;
count++; }
(A). 0
(B). 1
(C). 2
(D). 3
(E). None of these
Answer of Multiple Choice Question: (C). 2
Question: How many times will the following code print “welcome”?.
for ( int i = 0; i < 0; i++ )
{ cout << “Welcome” << endl;}
(A). 0
(B). 1
(C). 2
(D). 3
(E). None of these
Answer of Multiple Choice Question: (A). 0
Question: How many times will the following code print “I love my university”?.
for ( int i = 0; i >= 0; i++)
{ cout << “I love my university” << endl; }
(A). finite time
(B). infinite time
(C). 0
(D). 0 time or infinite time
(E). None of these
Answer of Multiple Choice Question: (B). infinite time
Question: How many times the following loop will execute to print “Hello dolly”?.
for ( int i = 1; i < 3; i + 2)
{ cout << “Hello dolly” << endl; }
(A). finite time
(B). infinite time
(C). 0
(D). 0 time or infinite time
(E). None of these
Answer of Multiple Choice Question: (B). infinite time
Question: How many times will the following code print “Hello World”?
for ( int i=1; i<3; i<3; i++)
{ cout << “Hello World” << endl; }
(A). shows error that “expected ‘)’ before ‘;’ token
(B). shows error that ‘i’ was not declared in this scope
(C). 2 times
(D). 3 times
(E). both a and b
Answer of Multiple Choice Question: (E). both a and b
Question: How many times the following for loop will execute in C++?
for ( int i=1+1; i<3; i++)
{ cout << “Welcome” << endl; }
(A). 0
(B). 1
(C). 2
(D). 3
(E). None of these
Answer of Multiple Choice Question: (B). 1
Question: What is the output of the following code in C++?
int a = 0;
do {
cout << a << endl;
a++;
}
while ( a < 1);
cout<<endl;
(A). 0
(B). 1
(C). 2
(D). 3
(E). None of these
Answer of Multiple Choice Question: (A). 0
Question: Find the output of the following code.
int a = 0 + 1;
do {
cout << a << endl;
a++;
}
while ( a <= 3);
cout<<endl;
(A). 0
(B). 1
(C). 2
(D). 3
(E). None of these
Answer of Multiple Choice Question: (D). 3
Question: Find the output of the following code.
int i,j;
i = 1;
do {
j = 1;
do {
cout << j;
j++;
} while ( j <=3 );
cout << “\n”;
i++;
} while ( i<=3 );
(A). 123
(B). 123123
(C). 123123123
(D). 123123123123
(E). None of these
Answer of Multiple Choice Question: (C). 123123123