Consider the following C program segment:
char p; int i;
char* s = "string";
int length = strlen(s);
for(i = 0; i < length; i++)
p[i] = s[length-i];
The output of the program is:
$p = s[length] = $ '\0'; //compiler puts a '\0' at the end of all string literals
Now, for any string function in C, it checks till the first '\0' to identify the end of string. So, since the first char is '\0', printf %s, will print empty string. If we use printf("%s", p+1); we will get option (C) with some possible garbage until some memory location happens to contain "\0". For the given code, answer is (D).
length is string= 6 it stores as string% end with endmarker%
for loop will make it = %gtrin [s is left out since we can store 6 letters, (a) is answer when sizeof is used intead of length]
Now print(p+1) = grint [ see here end marker is not present so after reaching index 20 it will halt.