C Programming - Strings - Discussion

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

int main()
{
    static char mess[6][30] = {"Don't walk in front of me...", 
                               "I may not follow;", 
                               "Don't walk behind me...", 
                               "Just walk beside me...", 
                               "And be my friend." };

    printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9));
    return 0;
}
t, t
k, k
n, k
m, f
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
21 comments Page 1 of 3.

Raju Singh Kumai said:   1 decade ago
*(mess[2]+9) can be written as mess[2][9] which implies 3 line 10 char.(in c we start from 0) which is 'k',

*(*(mess+2)+9))=*(mess[2]+9) = mess[2][9] = k.

So the output will be k, k.
(2)

Shadhu said:   5 years ago
@Sirisha.

Space is a character, comma is a separator.

So here we need to consider space also.
(1)

Smash said:   9 years ago
Thank you very much @Abhimanyu.

Shalini shah said:   3 months ago
How this executes? Please explain me.

Sirisha said:   7 years ago
How can we consider the space b/w words, is it seperator or character?

Roshni said:   8 years ago
Can anyone please explain it in details.

Eswari reddy said:   8 years ago
Thank you @Raghu.

Swati said:   8 years ago
Thanks @Abhimanyu.

Suraj said:   8 years ago
@Raju.

How you find k in line no 3 and char 10?

Ragini said:   8 years ago
There are 6 rows and 30 columns, so how you can say 6+1 rows and 30+1Columns.?

Please explain.


Post your comments here:

Your comments will be displayed after verification.