You are on page 1of 2

1- How many times 'its a while loop' should be printed?

           int i = 1 ;
     i=i-1;
        while(i)
       {
                cout<<"its a while loop";
               i++ ;
       }
A. 1
B. 2
C. 0
D. Infinite times
ANSWER: C
2- How many times 'its a while loop' should be printed?
           int i = 1 ;
     i=i-1;
        while(i)
       {
                cout<<"its a while loop";
               i++ ;
       }
E. 1
F. 2
G. 0
H. Infinite times
ANSWER: C

How many times CppBuzz.com is printed here?


 for(int i=1; i< 100; i++) ;
cout<<"CppBuzz.com";
A. 1
B. 100
C. 99
D. 0
ANSWER: 1
WHAT'S WRONG? for (int K = 2, K <=12, K++)
A. the increment should always be ++k
B. the variable must always be the letter i when using a for loop
C. there should be a semicolon at the end of the statement
D. the commas should be semicolons

ANSWER: D
Which looping process checks the test condition at the end of the loop?
A.  for .   
B. while .   
C. do-while .     
D. no looping process checks the test condition at the end .

ANSWER: C
If there is more than one statement in the block of a for loop, which of the following must be
placed at the beginning and the ending of the loop block?
A. parentheses ( ) 
B.     braces { }     
C. brackets [ ]     
D. arrows < >
ANSWER: B

which for loop will not work?


A. for (i=0; i<5; i++)
B. for (i=5; i<=10; i++)
C. for (i=5; i>10; i--)
D. non of the above.
ANSWER: C

 What would be the output from the following C++ code segment?
x=10;
while(x>5){
  cout<<x<<"\t";
  x--;
}
A. 10 9 8 7 6
B. 10 9 8 7 6 5
C. 1098765
D. 109876

ANSWER: A

You might also like