The GATE Grind

GATE Programming and Data Structures: Programming in C – Previous Year Questions

41 GATE previous year questions on Programming in C (Programming and Data Structures, Computer Science) with answers and explanations, from every paper.

  1. GATE 2017 CS Q23 (1 mark, Multiple choice) – Consider the following C code: The code suffers from which one of the following problems:
  2. GATE 2017 CS Q63 (2 marks, Numerical answer) – 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…
  3. GATE 2017 CS Q65 (2 marks, Numerical answer) – The output of executing the following C program is .
  4. GATE 2016 CS Q22 (1 mark, Multiple choice) – 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?
  5. GATE 2016 CS Q25 (1 mark, Numerical answer) – Consider the following C program. The output of the program is .
  6. GATE 2016 CS Q46 (2 marks, Multiple choice) – What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed?
  7. GATE 2015 CS Q16 (1 mark, Multiple choice) – Match the following: (P) Condition coverage (Q) Equivalence class partitioning (R) Volume testing (S) Alpha testing (i) Black-box testing (ii) System…
  8. GATE 2015 CS Q34 (1 mark, Numerical answer) – The output of the following C program is .
  9. GATE 2015 CS Q38 (2 marks, Numerical answer) – Consider the following C program segment. The cyclomatic complexity of the program segment is .
  10. GATE 2015 CS Q62 (2 marks, Multiple choice) – 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.
  11. GATE 2015 CS Q65 (2 marks, Multiple choice) – 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
  12. GATE 2018 CS Q12 (1 mark, Multiple choice) – Consider the following C program. The output of this program is:
  13. GATE 2018 CS Q39 (2 marks, Multiple choice) – Consider the following C program: The output of the program above is
  14. GATE 2018 CS Q42 (2 marks, Multiple choice) – 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
  15. GATE 2019 CS Q28 (1 mark, Numerical answer) – Consider the following C program: The value printed by the program is .
  16. GATE 2019 CS Q37 (2 marks, Multiple choice) – Consider the following C program: Which one of the following values will be displayed on execution of the programs?
  17. GATE 2019 CS Q62 (2 marks, Numerical answer) – Consider the following C program: The number of times the variable sum will be printed, when the above program is executed, is .
  18. GATE 2019 CS Q63 (2 marks, Numerical answer) – Consider the following C program: The output of the above C program is .
  19. GATE 2026 CS (CS2) Q17 (1 mark, Multiple choice) – In the C runtime environment, which one of the following is stored in the heap?
  20. GATE 2026 CS (CS2) Q19 (1 mark, Multiple choice) – Consider the following three ANSI C programs, P1, P2, and P3. Which one of the following statements is true?
  21. GATE 2026 CS (CS2) Q60 (2 marks, Numerical answer) – Consider the following ANSI C program. The output of this program is . (answer in integer) Note: Assume that the program compiles and runs…
  22. GATE 2026 CS (CS1) Q34 (1 mark, Numerical answer) – Consider the following program in C: The output of the program is . (answer in integer)
  23. GATE 2025 CS (CS2) Q19 (1 mark, Multiple choice) – Consider the following C program: Which ONE of the following will be the output of the program?
  24. GATE 2025 CS (CS2) Q33 (1 mark, Numerical answer) – The output of the given C code segment is . (Answer in integer)
  25. GATE 2025 CS (CS2) Q62 (2 marks, Numerical answer) – Consider the following C program: The output of the above program is . (Answer in integer)
  26. GATE 2025 CS (CS2) Q63 (2 marks, Numerical answer) – Consider the following C program: The output of the given C program is . (Answer in integer)
  27. GATE 2025 CS (CS1) Q34 (1 mark, Numerical answer) – The output of the given C program is . (Answer in integer)
  28. GATE 2025 CS (CS1) Q63 (2 marks, Numerical answer) – Consider the following C program: The value printed by the given C program is . (Answer in integer)
  29. GATE 2024 CS (CS2) Q13 (1 mark, Multiple choice) – 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…
  30. GATE 2024 CS (CS2) Q33 (1 mark, Multiple select) – Consider the following C function definition. Which of the following statements is/are TRUE?
  31. GATE 2024 CS (CS2) Q36 (2 marks, Multiple choice) – What is the output of the following C program?
  32. GATE 2024 CS (CS1) Q18 (1 mark, Multiple choice) – Consider the following C program: Which one of the following statements is CORRECT?
  33. GATE 2024 CS (CS1) Q48 (2 marks, Multiple select) – Consider the C function: Which of the following statements is/are TRUE about the above function?
  34. GATE 2023 CS Q35 (1 mark, Numerical answer) – The integer value printed by the ANSI-C program given below is .
  35. GATE 2022 CS Q21 (1 mark, Multiple choice) – What is printed by the following ANSI C program?
  36. GATE 2022 CS Q43 (2 marks, Multiple choice) – What is printed by the following ANSI C program?
  37. GATE 2022 CS Q44 (2 marks, Multiple choice) – What is printed by the following ANSI C program? ASCII: A–Z = 65–90, a–z = 97–122, '*' = 42, '+' = 43, '−' = 45.
  38. GATE 2021 CS Q47 (2 marks, Multiple choice) – Consider the following ANSI C program. Which one of the following options is correct?
  39. GATE 2021 CS Q58 (2 marks, Numerical answer) – 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…
  40. GATE 2020 CS Q32 (1 mark, Numerical answer) – Consider the following C program. The output of the program is .
  41. GATE 2020 CS Q58 (2 marks, Numerical answer) – Consider the following C functions. The value returned by pp(3,4) is .