Statements

1

Which looping process is best used when the number of iterations is known?

A. for
B. while
C. do-while
D. all looping processes require that the iterations be known

2

How many types of loops are there?

A. 4
B. 2
C. 3
D. 1

3

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        int i;
6.        
        for (i = 0; i < 10; i++);
7.        
        {
8.        
            cout << i;
9.            
        }
10.        
        return 0;
11.        
    }
A. 0123456789
B. 10
C. 012345678910
D. compile time error

4

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        int n = 15;
6.        
        for ( ; ;)
7.        
        cout << n;
8.        
        return 0;
9.        
    }

A. error
B. 15
C. infinite times of printing n
D. none of the mentioned

5

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        int a = 10;
6.        
        if (a < 15)
7.        
        {
8.        
            time:
9.            
            cout << a;
10.            
            goto time;
11.            
        }
12.        
        break;
13.        
        return 0;
14.        
    }
A. 1010
B. 10
C. infinitely print 10
D. compile time error