GATE Questions On C Programming
GATE Questions On C Programming
com
Download As PDF
Practicing previous years’ GATE Questions is a highly effective strategy for preparing for the
GATE Exam
. By solving these questions, candidates can refine their understanding of concepts, improve their analytical
skills, and enhance their time management abilities. This article comprises a collection of GATE Questions
on C programming, compiled for your convenience. We strongly recommend candidates to practice these
C programming GATE previous year questions to achieve the best results. C programming is a crucial topic
in the GATE CSE question paper, and practicing these questions will allow the candidates to prepare more
proficiently for the GATE exams. Below, in this article, you can find the GATE Questions for C programming
for your practice. You can also refer to these
GATE previous year question papers
for your exam preparation.
struct node {
int i;
float j;
};
struct node *s[10];
Answer: (a) The number of tokens in the following printf statement from the GATE CSE 2000 exam:
https://testbook.com/gate/c-programming-gate-questions 1/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
3
Overview Test Series
10
25
22
Answer: (b) For the given C code from the GATE CSE 2000 exam, assuming that objects of the type short,
float, and long occupy 2 bytes, 4 bytes, and 8 bytes, respectively, the memory requirement for variable t,
ignoring alignment is:
struct {
short s [5];
union {
float y;
long z;
}u;
} t;
22 bytes
18 bytes
14 bytes
10 bytes
Answer: (b) Consider the following three C functions from the GATE CSE 2001 exam:
Answer: (a) For the following C program from the GATE CSE 2011 exam, what does it print?
https://testbook.com/gate/c-programming-gate-questions 2/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
GATE 2011
2011
E2011
011
Answer: (b) Continuing with more C programming questions, the output of the following C program from
the GATE CSE 2015 Set 1 exam is:
-5
6
-6
0
Answer: (a) The following program from the GATE CSE 2010 exam prints:
22
21
https://testbook.com/gate/c-programming-gate-questions 3/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
01
Overview Test Series
02
Answer: (d) The given C program from the GATE CSE 2016 Set 1 exam:
Which one of the following expressions, when placed in the blank above, will NOT result in a type checking
error?
f(s,*s)
i = f(i,s)
f(i,*s)
f(i,*p)
Answer: (d) The output of the following C program from the GATE CSE 2018 exam is:
0, c
0, a+2
‘0’, ‘a+2’
‘0’,’c’
mystery(&a, &b);
Overview Test Series
if (a < c)
mystery(&c, &a);
mystery(&a, &d);
printf(“%d\n”, a);
}
2016
2018
016
16
6
5
66
0
Answer: (a) The most appropriate matching for the following pairs in the GATE CSE 2000 exam:
X: m=malloc(5); m= NULL;
Y: free(n); n->value = 5;
Z: char *p; *p=’a’;
1: using dangling
2: using uninitialized pointers
3. lost memory
Answer: (d) Consider the following C function from the GATE CSE 2004 exam:
https://testbook.com/gate/c-programming-gate-questions 5/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
Answer: (d) Assume the following C variable declaration from the GATE CSE 2003 exam:
I. A[2]
II. A[2] [3]
III. B[1]
IV. B[2] [3]
Which will not give compile-time errors if used as left-hand sides of assignment statements in a C
program?
I, II and IV
II, III and IV
II and IV
IV only
#include <stdio.h>
int jumble(int x, int y){
x=2*x+y;
return x;
}
int main(){
int x=2, y=5;
y=jumble(y,x);
x=jumble(y,x);
https://testbook.com/gate/c-programming-gate-questions 6/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
#include <stdio.h>
int main(){
int arr[]={1,2,3,4,5,6,7,8,9,0,1,2,5}, *ip=arr+4;
printf(“%d\n”, ip[1]);
return 0;
}
The number that will be displayed on execution of the program is _______ (GATE 2019)
6
7
8
0
Which one of the following will happen when the function convert is called with any positive integer n as
an argument? (GATE 2019)
It will print the binary representation of n and terminate
It will print the binary representation of n in the reverse order and terminate
It will print the binary representation of n but will not terminate
It will not print anything and will not terminate
#include <stdio.h>
void f (int *p, int *q) {
p = q;
*p = 2;
https://testbook.com/gate/c-programming-gate-questions 7/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
}
Overview Test Series
int i = 0, j = 1;
int main ( ){
f(&i, &j);
printf (“%d %d \ n”, i, j);
return 0;
}
Which one of the following values will be displayed on execution of the programs? (GATE 2019)
22
21
01
02
#include <stdio.h>
void printlength (char *s, char *t) {
unsigned int c=0;
int len = ((strlen(s) – strlen(t)) > c) ? strlen(s): strlen(t);
printf(“%d\n”,len);
}
void main () {
char *x = “abc”,
char *y = “defgh”;
printlength (x,y);
}
Recall that strlen is defined in string. h as returning a value of type size_t, which is an unsigned int. The
output of the program is _____ (GATE 2019)
3
5
7
9
#include <stdio.h>
int main () {
int arr [] = {1,2,3,4,5,6,7,8,9,0,1,2,5}, *ip = arr+4;
printf (“%d\n”, ip[1]);
return 0;
}
https://testbook.com/gate/c-programming-gate-questions 8/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
0
Overview Test Series
Answer: (a) The most appropriate matching for the following pairs:
X: m=malloc(5); m= NULL;
Y: free(n); n->value = 5;
Z: char *p; *p=’a’;
1: using dangling
2: using uninitialized pointers
3. lost memory
(GATE 2019)
X-1 Y-3 Z-2
X-2 Y-1 Z-3
X-3 Y-2 Z-1
X-3 Y-1 Z-2
I. A[2]
II. A[2] [3]
III. B[1]
IV. B[2] [3]
Which will not give compile-time errors if used as left-hand sides of assignment statements in a C
program?
I, II and IV
II, III and IV
II and IV
IV only
https://testbook.com/gate/c-programming-gate-questions 9/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
#include <stdio.h>
int jumble(int x, int y){
x=2*x+y;
return x;
}
int main(){
int x=2, y=5;
y=jumble(y,x);
x=jumble(y,x);
printf(“%d \n”, x);
return 0;
}
#include <stdio.h>
int main(){
int arr[]={1,2,3,4,5,6,7,8,9,0,1,2,5}, *ip=arr+4;
printf(“%d\n”, ip[1]);
return 0;
}
https://testbook.com/gate/c-programming-gate-questions 10/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
0
Overview Test Series
Which one of the following will happen when the function convert is called with any positive integer n as
an argument?
It will print the binary representation of n and terminate
It will print the binary representation of n in the reverse order and terminate
It will print the binary representation of n but will not terminate
It will not print anything and will not terminate
#include <stdio.h>
void f (int *p, int *q) {
p = q;
*p = 2;
}
int i = 0, j = 1;
int main ( ){
f(&i, &j);
printf (“%d %d \ n”, i, j);
return 0;
}
Which one of the following values will be displayed on execution of the programs?
22
21
01
02
#include <stdio.h>
void printlength (char *s, char *t) {
unsigned int c=0;
int len = ((strlen(s) – strlen(t)) > c) ? strlen(s): strlen(t);
printf(“%d\n”,len);
}
void main () {
https://testbook.com/gate/c-programming-gate-questions 11/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
char *x = “abc”,
Overview Test Series
char *y = “defgh”;
printlength (x,y);
}
Recall that strlen is defined in string. h as returning a value of type size_t, which is an unsigned int. The
output of the program is _____
3
5
7
9
#include <stdio.h>
int main () {
int arr [] = {1,2,3,4,5,6,7,8,9,0,1,2,5}, *ip = arr+4;
printf (“%d\n”, ip[1]);
return 0;
}
Answer: (a) The most appropriate matching for the following pairs:
X: m=malloc(5); m= NULL;
Y: free(n); n->value = 5;
Z: char *p; *p=’a’;
1: using dangling
2: using uninitialized pointers
3. lost memory
https://testbook.com/gate/c-programming-gate-questions 12/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
In order to Test
Overview exchange
Series the values of two variables x and y:
call swap (x,y)
call swap (&x, &y)
swap (x, y) cannot be used as it does return any value
swap (x,y) cannot be used as the parameters are passed by value
I. A[2]
II. A[2] [3]
III. B[1]
IV. B[2] [3]
Which will not give compile-time errors if used as left-hand sides of assignment statements in a C
program?
I, II and IV
II, III and IV
II and IV
IV only
Answer: (b) Continue learning and stay tuned for the latest updates on the
GATE Syllabus for CSE (Computer Science Engineering)
,
Introduction to C Programming
,
GATE CSE Question Paper
, and more
https://testbook.com/gate/c-programming-gate-questions 13/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
Closure
Overview Properties
Test Series of Context-Free Languages (CFLs)
Where can I find GATE previous year question papers for C programming?
₹11399 ₹4769
Purchase Now
https://testbook.com/gate/c-programming-gate-questions 14/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
Want
Overview toTest
knowSeriesmore about this Super Coaching ? Explore SuperCoaching Now
₹4769 (Valid for 6 Months) ₹13416 (Valid till June 2026 Ex ₹0 (Valid for 1 year)
https://testbook.com/gate/c-programming-gate-questions 15/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
Test Series
https://testbook.com/gate/c-programming-gate-questions 16/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
GATE Mathematics & GATE CSE 2023-24 Test GATE CE 2025-26 Test
General Aptitude (Commo… Series Series
92 Total Tests 129 Total Tests | 1 Free Tests 160 Total Tests | 1 Free Tests
View More
Report An Error
Super Coaching
https://testbook.com/gate/c-programming-gate-questions 17/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
Test Series
GATE Petroleum Engineering Previous Years Papers GATE Textile Engineering and Fibre Science Previous
Overview Test Series
GATE Agricultural Engineering Previous Year Papers Years Papers
GATE 2022 Question Papers GATE 2021 Question Papers
GATE 2018 Question Papers GATE 2017 Question Papers
GATE 2014 Question Papers GATE 2013 Question Papers
Company
About us
Careers We are hiring
Testbook Edu Solutions Pvt. Ltd. Teach Online on Testbook
D- 1, Vyapar Marg, Media
Noida Sector 3, Noida, Sitemap
Uttar Pradesh, India - 201301
[email protected]
Toll Free:
1800 203 0577
Office Hours: 10 AM to 7 PM (all 7 days)
Test Series
Live Tests and Quizzes
Testbook Pass
Online Videos
Practice Follow us on
Live Classes
Blog
Refer & Earn
Books
Exam Calendar
GK & CA
Teacher Training Program
Doubts
Hire from SkillAcademy
Copyright © 2014-2024 Testbook Edu Solutions Pvt. Ltd.: All rights reserved
https://testbook.com/gate/c-programming-gate-questions 19/20
17/11/2025, 11:41 GATE Questions on C Programming - Testbook.com
https://testbook.com/gate/c-programming-gate-questions 20/20