C Programming - Strings - Discussion

Discussion Forum : Strings - Find Output of Program (Q.No. 13)
13.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    static char s[25] = "The cocaine man";
    int i=0;
    char ch;
    ch = s[++i];
    printf("%c", ch);
    ch = s[i++];
    printf("%c", ch);
    ch = i++[s];
    printf("%c", ch);
    ch = ++i[s];
    printf("%c", ch);
    return 0;
}
hhe!
he c
The c
Hhec
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
34 comments Page 4 of 4.

Wikiok said:   1 decade ago
++i[s] <-> ++(i[s]) <-> ++(s[i])

Devnath said:   1 decade ago
Replace 48 by 32, because white space ascii value is 32, and 33 is for "!".

Sumit said:   1 decade ago
Because here we are incrementing the value of s[4]. Before its space that is having ascii value 48 after incrementing it ll become '!'.

Nikhil said:   1 decade ago
How does an exclamation mark come?


Post your comments here:

Your comments will be displayed after verification.