1
GATE CSE 2021 Set 2
MCQ (Single Correct Answer)
+2
-0.66
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 ?
2
GATE CSE 2019
Numerical
+2
-0
Consider the following C program:
The output of the above C program is _________.
#include < stdio.h >
int main()
{
int a[] = {2, 4, 6, 8, 10} ;
int i, sum = 0, *b = a + 4 ;
for (i = 0; i < 5; i++)
sum = sum + (*b - i) - *(b - i) ;
printf ("%d\n", sum) ;
return 0 ;
}
The output of the above C program is _________.
Your input ____
3
GATE CSE 2018
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
#include< stdio.h >
void fun1(char *s1, char *s2){
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
void fun2(char **s1, char **s2){
char *tmp;
tmp = *s1;
*s1 = *s2;
*s2 = tmp;
}
int main(){
char *str1 = "Hi", *str2 = "Bye";
fun1(str1, str2); printf("%s %s ", str1, str2);
fun2(&str1, &str2); printf("%s %s", str1, str2);
return 0;
}
The output of the program above is4
GATE CSE 2015 Set 1
MCQ (Single Correct Answer)
+2
-0.6
What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory.
int main () {
unsigned int x[4][3] =
{{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
printf(“%u, %u, %u”, x+3, *(x+3), *(x+2)+3);
}
Questions Asked from Pointer and Structure in C (Marks 2)
Number in Brackets after Paper Indicates No. of Questions
GATE CSE Subjects
Theory of Computation
Operating Systems
Algorithms
Database Management System
Data Structures
Computer Networks
Software Engineering
Compiler Design
Web Technologies
General Aptitude
Discrete Mathematics
Programming Languages