What will be the output of the following code? int main()
What will be the output of the following code?
#include <stdio.h>
int main()
{
char str[20] = "Hello, World!";
printf("%s\n", str + 7);
return 0;
}
Show answerHide answer
Correct answer: (A) World!
Explanation
str + 7 points to index 7 of "Hello, World!". Index 5 is ',' and 6 is the space, so printing starts at 'W' and gives "World!".