GATE | GATE-CS-2004 | Question 33

Consider the following C program segment:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


The output of the program is (GATE CS 2004)

(A) gnirts
(B) gnirt
(C) string
(D) no output is printed


Answer: (D)

Explanation: See question 1 of https://www.geeksforgeeks.org/c-language-set-2/

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.