Programming - C++ Language

You Are Here :: Home > C++ Language > Arrays - General Questions

 
19.

Consider the following declaration:
int beta[3];
int j;
Which of the following input statements correctly inputs values into beta?
(i)
cin>>beta[0]
>>beta[1]
>>beta[2];
(ii)
for(j = 0; j < 3; j++)
cin>>beta[j];                         


A. Only (i) B. Only (ii)
C. Both (i) and (ii) D. None of these




20.

What is the output of the following C++ code?
int list[5] = {0, 5, 10, 15, 20};
int j;
for(j = 0; j < 5; j++)
cout<cout<                        


A. 0 1 2 3 4 B. 0 5 10 15 20
C. 0 5 10 15 D. None of these




21.

What is the output of the following C++ code?
int list[5] = {0, 5, 10, 15, 20};
int j;
for(j = 1; j <= 5; j++)
cout<cout<                        


A. 0 5 10 15 20 B. 5 10 15 20 0
C. 5 10 15 20 20 D. Code contains index out-of-bound




22.

Given the declaration
int gamma[50];
int j;
Which of the following for loop sets the index of gamma out of bound?
(i)
for(j = 0; j <= 49; j++)
cout<(ii)
for(j = 1; j < 50; j++)
cout<(iii)
for(j = 0; j <= 50; j++)
cout<                        


A. Only (i) B. Only (ii)
C. Only (iii) D. All (i), (ii), and (iii)




23.

What is the value of alpha[2] after the following code executes?
int alpha[5];
int j;
for(j = 0; j < 5; j++)
alpha[j] = 2 * j + 1;                         


A. 1 B. 4
C. 5 D. 6




24.

What is the value of alpha[4] after the following code executes?
int alpha[5];
int j;
alpha[0] = 2;
for(j = 1; j < 5; j++)
alpha[j] = alpha[j – 1] + 3;                         


A. 5 B. 8
C. 11 D. 14




« prev

1

2

3

4

5

6

7

8

9

next »

 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on