Programming - C++ Language

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

 
13.

Consider the following declaration:
int list[10];
int j;,br>Which of the following correctly outputs all the elements of list?
(i)
for(j = 1; j < 10; j++)
cout<cout<(ii)
for(j = 0; j <= 9; j++)
cout<cout<                        


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




14.

Consider the following declaration:
double sales[50];
int j;
Which of the following correctly initializes the array sales to 0?
(i)
for(j = 0; j < 49; j++)
sales[j] = 0;
(ii)
for(j = 1; j <= 50; j++)
sales[j] = 0;                         


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




15.

Consider the following declaration:
int list[10];
int j;
int sum;
Which of the following correctly finds the sum of the elements of list?
(i)
sum = 0;
for(j = 0; j < 10; j++)
sum = sum + list[j];
(ii)
sum = list[0];
for(j = 1; j < 10; j++)
sum = sum + list[j];                         


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




16.

Which of the following statements declares alpha to be an array of 5 components of the type int and initializes each component to 0?
(i) int alpha[5] = {0, 0, 0, 0, 0};
(ii) int alpha[5] = {0};                         


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




17.

Consider the following declaration:
int alpha[5] = {3, 5, 7, 9, 11};
Which of the following statements is equivalent to this statement?
(i) int alpha[] = {3, 5, 7, 9, 11};
(ii) int alpha[5] = {3 5 7 9 11};                         


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




18.

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


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




« prev

1

2

3

4

5

6

7

8

9

next »

 
 



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