GATE | Gate IT 2008 | Question 47
What is the output printed by the following C code?
# include <stdio.h>
int main ()
{
char a [6] = "world" ;
int i, j;
for (i = 0, j = 5; i < j; a [i++] = a [j--]);
printf ( "%s\n" , a);
}
|
(A) dlrow
(B) Null String
(C) dlrld
(D) worow
Answer: (B)
Explanation: As at the base address or starting of the string “Null” is placed, so while reading array if Null comes it assumes that this is the end of array, so it terminates here only.
Quiz of this Question
Last Updated :
28 Jun, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...