Programming - C++ Language

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

 
25.

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


A. 10 B. 13
C. 15 D. None of these




26.

What is stored in alpha after the following code executes?
int alpha[5];
int j;
for(j = 0; j < 5; j++)
{
alpha[j] = j + 5;
if(j % 2 == 1)
alpha[j - 1] = alpha[j] + 2;
}                         


A. alpha = {5, 6, 7, 8, 9} B. alpha = {5, 6, 10, 8, 9}
C. alpha = {8, 6, 7, 8, 9} D. alpha = {8, 6, 10, 8, 9}




27.

What is stored in alpha after the following code executes?
int alpha[5];
int j;
for(j = 0; j < 5; j++)
{
alpha[j] = 2 * j;
if(j % 2 == 1)
alpha[j - 1] = alpha[j] + j;
}                         


A. alpha = {0, 2, 4, 6, 8} B. alpha = {3, 2, 9, 6, 8}
C. alpha = {0, 3, 4, 7, 8} D. alpha = {0, 2, 9, 6, 8}




28.

What is stored in alpha after the following code executes?
int alpha[5];
int j;
for(j = 0; j < 5; j++)
{
alpha[j] = j + 1;
if(j > 2)
alpha[j - 1] = alpha[j] + 2;
}                         


A. alpha = {1, 5, 6, 7, 5} B. alpha = {1, 2, 3, 4, 5}
C. alpha = {4, 5, 6, 7, 9} D. None of these




29.

What is the output of the following C++ code?
int alpha[5] = {2, 4, 6, 8, 10};
int j;
for(j = 4; j >= 0; j--)
cout<cout<                        


A. 2 4 6 8 10 B. 10 8 6 4 2
C. 4 3 2 1 0 D. Invalid code




30.

What is the value of alpha[3] after the following code executes?
int alpha[5];
int j;
for(j = 4; j >= ; j--)
{
alpha[j] = j + 5;
if(j <= 2)
alpha[j + 1] = alpha[j] + 3;
}                         


A. 5 B. 8
C. 9 D. 10




« prev

1

2

3

4

5

6

7

8

9

next »

 
 



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