Out-Put

closed account (LE3bqMoL)
The out-put for this program will be: 'LKJIH'?


char chs[5];
chs[4] = ‘H’;
for ( int i=3; i>=0; i--)
chs[i] = chs[i+1] + 1;
for (int i=0; i<5; i++)
cout<<chs[i];
What's your question?
closed account (LE3bqMoL)
Is the output correct??
Last edited on
If you want to check it you can try compiling it.
Following your program's logic:
1
2
3
4
5
6
char chs[5];// chs = ?????
chs[4] = ‘H’;// chs = ????H
for ( int i=3; i>=0; i--)
    chs[i] = chs[i+1] + 1;// chs = ???IH, chs = ??JIH, chs = ?KJIH, chs = LKJIH
for (int i=0; i<5; i++)
    cout<<chs[i];
the '?' are uninitialized values
closed account (LE3bqMoL)
So is my answer correct??? or am I forgetting something???
Last edited on
Compile and check.

Nobody is going to compile your code for you because you are too lazy to do it yourself.

Sorry if I'm being to harsh but some things require a little common sense.
Topic archived. No new replies allowed.