GATE Computer Science (CS) 2021 Shift 2 Solved Paper

© examsiri.com
Question : 45 of 65
 
Marks: +1, -0
Consider the following ANSI C program:
#include <stdio.h>
#include <stdlib.h>
struct Node{
int value;
struct Nodeʉܠnext;};
int main(){
struct NodeʉܠboxE,ʉܠhead,ʉܠboxN; int index = 0;
boxE = head = (struct Nodeʉܠ) malloc (sizeof(struct Node));
head -> value = index;
for (index = 1; index <=3; index++){
boxN = (struct Nodeʉܠ) malloc(sizeof(struct Node));
boxE -> next = boxN;
boxN -> value = index;
boxE = boxN; }
for (index = 0; index <= 3; index++) {
printf("value at index %d is %d\m", index, head -> value);
head = head -> next;
printf("value at index %d is %d\n", index + 1, head -> value);}}

Which one of the statement below is correct about the program ?
Go to Question: