Consider the following C program segment: char p[20]; char *s = "string"; int…

GATE · 2004 · CS

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

  1. A.

    gnirts

  2. B.

    string

  3. C.

    gnirt

  4. D.

    no output is printed

Attempted by 164 students.

Sign up free to check your answer

Sign up free

Explore the full course: Isro

Loading lesson…