Gate CS-2004 Question Paper With Solutions

Q. 78 Consider the following C program segment:

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

The output of the program is

(A) gnirts

(B) string

(C) gnirt

(D) no output is printed

Answer: (D)

Explanation:

Gate CS-2004 Question Paper With Solutions

Learn More:   Gate EC-2015 - 3 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here