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.

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).

Ketan kumhar said:   4 years ago
@All.

Here is my coding;

#include<stdio.h>
int main()
{
char str[]="Hello World";
printf("%s"5+str);
return 0;
}
(1)


Post your comments here:

Your comments will be displayed after verification.