GATE Programming and Data Structures: Programming in C – Previous Year Questions
68 GATE previous year questions on Programming in C (Programming and Data Structures, Computer Science) with answers and explanations, from every paper.
68 questions worth 106 marks in all (30 1-mark, 38 2-mark). Asked between 2008 and 2026, so you can see how the topic has been tested over time.
- GATE 2008 CS Q18 – Which values make a=4?
- GATE 2008 CS Q60 – What is printed by this C program?
- GATE 2008 CS Q84 – The following erroneous C program attempts binary search in Y[10]: On which input does it fail?
- GATE 2008 CS Q85 – The following erroneous C program attempts binary search in Y[10]: Which correction makes it work properly?
- GATE 2015 CS (CS3) Q11 – What is printed?
- GATE 2015 CS (CS3) Q42 – What is printed?
- GATE 2015 CS (CS3) Q43 – What is printed?
- GATE 2015 CS (CS3) Q53 – How many times is printf executed?
- GATE 2015 CS (CS2) Q52 – What does this C program print?
- GATE 2010 CS Q21 – What is printed?
- GATE 2011 CS Q32 – What is printed?
- GATE 2013 CS Q60 – A has length five; oldc,newc each have length three. The intended operation replaces each original A character at most once using the corresponding…
- GATE 2013 CS Q61 – A has length five; oldc,newc each have length three. The intended operation replaces each original A character at most once using the corresponding…
- GATE 2012 CS Q13 – Find the output of the printed C fragment. Several case labels below retain the source’s semicolons.
- GATE 2012 CS Q58 – What are the three output lines?
- GATE 2012 CS Q59 – For the same complete code below, replace Line 1 with auto int a=1 and Line 2 with register int a=2. What are the three output lines?
- GATE 2017 CS (CS2) Q12 – Match (P) static char var; (Q) m = malloc(10); m = NULL; (R) char *ptr[10]; (S) register int var1; with (i) sequence of memory locations storing…
- GATE 2017 CS (CS2) Q24 – What is printed by printxy(1,1)?
- GATE 2017 CS (CS2) Q47 – The following fragment divides x by y using repeated subtraction. All variables x,y,q,r are unsigned int. Which precondition ensures termination with…
- GATE 2017 CS (CS2) Q53 – swap exchanges its two arguments. Find the output.
- GATE 2017 CS (CS2) Q64 – Find the C program output.
- GATE 2017 CS (CS2) Q65 – Find the C program output.
- GATE 2016 CS (CS2) Q22 – What does this C program print?
- GATE 2016 CS (CS2) Q45 – This function computes XY for positive integers. Which invariant holds before every loop iteration?
- GATE 2014 CS (CS2) Q20 – For the C function below, find func(435). int func(int num) int count = 0; while (num) count++; num >>= 1; return count;
- GATE 2014 CS (CS2) Q21 – n and p are unsigned int in C. To set p to n choose 3 for large n, which is most likely correct?
- GATE 2014 CS (CS1) Q20 – Consider this C program: #include <stdio.h> main() int i; int *pi = &i; scanf("%d", pi); printf("%d", i+5); Which statement is TRUE?
- GATE 2017 CS (CS1) Q23 – Consider the following C code: The code suffers from which one of the following problems:
- GATE 2017 CS (CS1) Q63 – Consider the following C program. Recall that `strlen` is defined in `string.h` as returning a value of type `size t`, which is an `unsigned int`. The…
- GATE 2017 CS (CS1) Q65 – The output of executing the following C program is .
- GATE 2016 CS (CS1) Q22 – Consider the following C program. Which one of the following expressions, when placed in the blank above, will NOT result in a type checking error?
- GATE 2016 CS (CS1) Q25 – Consider the following C program. The output of the program is .
- GATE 2016 CS (CS1) Q46 – What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed?
- GATE 2015 CS (CS1) Q16 – Match the following: (P) Condition coverage (Q) Equivalence class partitioning (R) Volume testing (S) Alpha testing (i) Black-box testing (ii) System…
- GATE 2015 CS (CS1) Q34 – The output of the following C program is .
- GATE 2015 CS (CS1) Q38 – Consider the following C program segment. The cyclomatic complexity of the program segment is .
- GATE 2015 CS (CS1) Q62 – 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.
- GATE 2015 CS (CS1) Q65 – Consider the following pseudo code, where x and y are positive integers. The post condition that needs to be satisfied after the program terminates is
- GATE 2018 CS Q12 – Consider the following C program. The output of this program is:
- GATE 2018 CS Q39 – Consider the following C program: The output of the program above is
- GATE 2018 CS Q42 – Consider the following C code. Assume that `unsigned long int` type length is 64 bits. The value returned when we call `fun` with the input 240 is
- GATE 2019 CS Q28 – Consider the following C program: The value printed by the program is .
- GATE 2019 CS Q37 – Consider the following C program: Which one of the following values will be displayed on execution of the programs?
- GATE 2019 CS Q62 – Consider the following C program: The number of times the variable sum will be printed, when the above program is executed, is .
- GATE 2019 CS Q63 – Consider the following C program: The output of the above C program is .
- GATE 2026 CS (CS2) Q17 – In the C runtime environment, which one of the following is stored in the heap?
- GATE 2026 CS (CS2) Q19 – Consider the following three ANSI C programs, P1, P2, and P3. Which one of the following statements is true?
- GATE 2026 CS (CS2) Q60 – Consider the following ANSI C program. The output of this program is . (answer in integer) Note: Assume that the program compiles and runs…
- GATE 2026 CS (CS1) Q34 – Consider the following program in C: The output of the program is . (answer in integer)
- GATE 2025 CS (CS2) Q19 – Consider the following C program: Which ONE of the following will be the output of the program?
- GATE 2025 CS (CS2) Q33 – The output of the given C code segment is . (Answer in integer)
- GATE 2025 CS (CS2) Q62 – Consider the following C program: The output of the above program is . (Answer in integer)
- GATE 2025 CS (CS2) Q63 – Consider the following C program: The output of the given C program is . (Answer in integer)
- GATE 2025 CS (CS1) Q34 – The output of the given C program is . (Answer in integer)
- GATE 2025 CS (CS1) Q63 – Consider the following C program: The value printed by the given C program is . (Answer in integer)
- GATE 2024 CS (CS2) Q13 – Consider the following C program. Assume parameters to a function are evaluated from right to left. Which one of the following options is the CORRECT…
- GATE 2024 CS (CS2) Q33 – Consider the following C function definition. Which of the following statements is/are TRUE?
- GATE 2024 CS (CS2) Q36 – What is the output of the following C program?
- GATE 2024 CS (CS1) Q18 – Consider the following C program: Which one of the following statements is CORRECT?
- GATE 2024 CS (CS1) Q48 – Consider the C function: Which of the following statements is/are TRUE about the above function?
- GATE 2023 CS Q35 – The integer value printed by the ANSI-C program given below is .
- GATE 2022 CS Q21 – What is printed by the following ANSI C program?
- GATE 2022 CS Q43 – What is printed by the following ANSI C program?
- GATE 2022 CS Q44 – What is printed by the following ANSI C program? ASCII: A–Z = 65–90, a–z = 97–122, '*' = 42, '+' = 43, '−' = 45.
- GATE 2021 CS (CS1) Q47 – Consider the following ANSI C program. Which one of the following options is correct?
- GATE 2021 CS (CS1) Q58 – Consider the following ANSI C function: Let Z be an array of 10 elements with Z[i]=1, for all i such that 0 i 9. The value returned by…
- GATE 2020 CS Q32 – Consider the following C program. The output of the program is .
- GATE 2020 CS Q58 – Consider the following C functions. The value returned by pp(3,4) is .