Open In App

GATE | Gate IT 2008 | Question 47

Last Updated : 28 Jun, 2021
Like Article
Like
Save
Share
Report

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);
}
 /* Add code here. Remove these lines if not writing code */ 


(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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads