...
Question 9519 – C-Programming
November 11, 2023
Pointers
November 11, 2023
Question 9519 – C-Programming
November 11, 2023
Pointers
November 11, 2023

Question 9521 – C-Programming

Consider the following C program segment:

     char p[20];
     char *s = "string";
     int length = strlen(s);
     int i;
     for (i = 0; i < length; i++)
          p[i] = s[length — i];
     printf("%s",p); 

The output of the program is

Correct Answer: D

Question 9 Explanation: 
Every string is to be end with ‘\0’.
P[0] = S[7-1] = S[6] = \0.
In P[ ], the first character is ‘\0’. Then it will results a empty string. If P[0] become ‘\0’, then it doesn’t consider about next values in sequence.
A
gnirts
B
string
C
gnirt
D
no output is printed
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x