Search⌘ K
AI Features

Superhero’s Secret Identity

Explore the Superhero Secret Identity puzzle to enhance your logical thinking and C programming skills. Learn to analyze code output accurately and strengthen your understanding of code behavior through hands-on problem solving.

We'll cover the following...

Puzzle code

Read carefully the code given below:

C++
#include <stdio.h>
#define SIZE 5
int main()
{
int values[SIZE] = {2, 3, 5, 8, 13};
int *v, x;
/* initialize the pointer */
v = values;
for( x=0; x<SIZE; x++ ) {
printf("%2d = %2d\n",
values[x],
*(v+x)
);
}
return(0);
}

Your task: Guess the output

Attempt the following test to assess your understanding.

Technical Quiz
1.

What is the expected output of the above code?

A.
2 =  2
3 =  3
5 =  5
8 =  8
13 = 13
B.
2 =  3
3 =  5
5 =  8
8 = 13
13 =  2
C.
2 =  2
3 =  5
5 =  8
8 = 13
13 =  2
D.
2 =  8
3 = 13
5 =  2
8 =  3
13 =  5

1 / 1

Let's discuss the code and output together in the next lesson.