C Programming - Strings - Discussion

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

int main()
{
    printf(5+"Good Morning\n");
    return 0;
}
Good Morning
Good
M
Morning
Answer: Option
Explanation:

printf(5+"Good Morning\n"); It skips the 5 characters and prints the given string.

Hence the output is "Morning"

Discussion:
12 comments Page 2 of 2.

Moni Gupta said:   4 years ago
Skip 5 that means till m then why print morning it should be orning.

Deepak said:   4 years ago
After skipping a+5=0+5=5 It returns the pointer as 6...And 6th letter is 'M'.
Note: Space should be count.
4+1(space).


Post your comments here:

Your comments will be displayed after verification.