C++ output type question

Q.  Trace the output.

void main ( )
{

char s[ ] = "CLASS";
int i;
for (i=0; s[i]; i++)
cout << "\n" << s[i] << *(s+i) << *(i + s) << i[s];
}

- Published on 17 Jun 15

a.
C
L
A
S
S
b.
CLASS
CLASS
CLASS
CLASS
CLASS
c.
CCCC
LLLL
AAAA
SSSS
SSSS
d. None of the above.

ANSWER:
CCCC
LLLL
AAAA
SSSS
SSSS

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)