Programming - Arrays - Discussion

You Are Here :: Home > C++ Language > Arrays - Discussion

 



Q.

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}

Answer: Option B
Explaination:

 


No Explanation




Discussion

Your Comments Goes here...
NameDiscussion