Question discussion

What will be the output of the following code?

359032Medium DSSSB TGT Computer Science 0 replies 0 views
0
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;
}
  • AWorld!
  • B, World!
  • CCompilation error
  • DHello, World!
Correct answer: A

Explanation

str + 7 points to the 8th character, so printf prints "World!".

Discussion 0

Nobody has replied yet. Start the discussion!