Loops
1.

What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run ?

A.  

10

B.  

9

C.  

0

D.  

1

2.

What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run ?

A.  

10

B.  

9

C.  

0

D.  

1

3.

When does the code block following while(x<100) execute ?

A.  

When x is less than one hundred

B.  

When x is greater than one hundred

C.  

When x is equal to one hundred

D.  

While it wishes

4.

Which is not a loop structure ?

A.  

For

B.  

Do while

C.  

While 

D.  

Repeat Until

5.

 How many times is a do while loop guaranteed to loop ?

A.  

0

B.  

Infinitely

C.  

1

D.  

Variable

6.

How many loops are there in C++ 98 ?

A.  

2

B.  

3

C.  

4

D.  

1

7.

What is currect syntax of for loop ?

A.  

for(initialization;condition; increment/decrement)

B.  

for(increment/decrement; initialization; condition)

C.  

for(initialization, condition, increment/decrement

D.  

None of These

8.

How many times CppBuzz.com is printed ?

int main()
{
   int i=0;
   lbl:
   cout<<"CppBuzz.com";
   i++;
   if(i<5)
   {
goto lbl;
   }
return 0;

}

 

A.  

Error

B.  

5 times

C.  

4 times

D.  

6 times

9.

Can a for loop contain another for loop ?

A.  

No

B.  

Yes

C.  

Compilation Error

D.  

Runtime Error

10.

Find the output of below program:-


int main()  
{
int i = 0, x = 0;

do
{
   if(i % 5 == 0)
   {
      cout<<x;
      x++;
   }

   ++i;
}while(i<10);

cout<<x;

return 0;
}

 

A.  

01

B.  

012

C.  

0

D.  

0123