Skip to content
Early access — you're among the first to try PYQLabs. Share feedback

GATE CSE & IT

2,749 questions · 40 years · 20 subjects

Public preview: use this branch page to find high-signal topics and keyed questions. Explanations are being added selectively, starting with recent and recurring concepts.

Worked PYQ examples

Open a few full study-layer explanations before signing in.

Browse explained PYQs →

High-yield topics

All trends →

Practice CSE & IT PYQs

80 questions shown in Programming Languages. Filter for cleaner practice sessions.

Showing Programming Languages PYQs from CSE & IT.
2026 PYQ

Consider the recursive functions represented by the following code segment: int bar(int n){ if (n == 1) return 0; else return 1 + bar(n/2); } int foo(int n){ if (n == 1) return 1;...

Programming Languages/NAT
2026 PYQ

In C runtime environment, which one of the following is stored in heap?

Programming Languages/MCQ/answer key/explanation
2026 PYQ

Consider the following program in C: #include <stdio.h> void func(int i, int j) { if(i < j) { int i = 0; while (i < 10) { j += 2; i++; } } printf("%d", i); } int main() { int i = 9...

Programming Languages/NAT/explanation
2026 PYQ

Consider the following ANSI-C function. int func(int start, int end){ int length = end + 1 - start; if((length<1)| (start < 0)||(end<0)){ return(0); } if(length%3 == 0){ return(fun...

Programming Languages/INTEGER/explanation
2026 PYQ

Consider the following ANSI-C program. #include <stdio.h> int main( ) { int *ptr, a, b, c; a=5; b=11; c=20; ptr=&a; *ptr=c; ptr=&c; a=*(&b); c=*ptr-a; printf("%d",c); return(0); }...

Programming Languages/NAT
2025 PYQ

#include <stdio.h> int foo(int S[ ], int size) { if(size == 0) return 0; if(size == 1) return 1; if(S[0]!=S[1]) return 1 + foo(S + 1, size - 1); return foo(S + 1, size - 1); } int...

Programming Languages/NAT/explanation
2025 PYQ

#include void foo(int *p, int x) { *p = x; } int main( ) { int *z; int a = 20, b=25; z = &a; foo(z, b); printf("%d", a); return 0; } The output of the given C program is _________....

Programming Languages/NAT/explanation
2025 PYQ

Consider the following C program : #include int gate (int n) { int d, t, newnum, turn; newnum = turn = 0; t=1; while (n>= t) t*= 10; t/=10; while (t>0) { d=n/t; n=n%t; t/= 10; if (...

Programming Languages/NAT/explanation
2025 PYQ

Consider the following C program : #include <stdio.h> int g(int n) { return (n+10); } int f(int n) { return g(n*2); } int main() { int sum, n; sum=0; for (n=1; n The output of the...

Programming Languages/NAT/explanation
2025 PYQ

Consider the following C program : #include <stdio.h> int main( ) { int a; int arr[5]={30,50,10}; int *ptr; ptr = &arr[0] + 1; a = *ptr; (*ptr)++; ptr++; printf("%d",a + (*ptr) + a...

Programming Languages/NAT
2025 PYQ

Consider the following C program : #include <stdio.h> void stringcopy(char *, char *); int main( ) { char a[30] = "@#Hello world!"; stringcopy(a,a+2); printf("%s\n", a); return 0;...

Programming Languages/MCQ/answer key/explanation
2025 PYQ

int x = 126, y = 105; do{ if(x > y) x = x - y; else y = y - x; }while(x!=y); printf('%d", x); The output of the given C code segment is __________. (Answer in integer)

Programming Languages/NAT/explanation
2024 PYQ

Consider the following C program: #include &ltstdio.h> int main() { int a = 6; int b = 0; while(a Which one of the following statements is CORRECT?

Programming Languages/MCQ/answer key/explanation
2024 PYQ

Consider the following C program: #include <stdio.h> void fX(); int main() { fX(); return 0;} void fX() { char a; if ((a = getchar()) != '\n') fX(); if (a != '\n') putchar(a);} Ass...

Programming Languages/MCQ/answer key/explanation
2024 PYQ

Consider the following C function definition. int f(int x, int y) { for (int i=0; i<y; i++) { x=x+x+y; } return x; } Which of the following statements is/are TRUE about the above f...

Programming Languages/MSQ/answer key/explanation
2024 PYQ

Consider the following C program. Assume parameters to a function are evaluated from right to left. #include <studio.h> int g(int p) { printf("%d", p); return p; } int h(int q) { p...

Programming Languages/MCQ/answer key/explanation
2024 PYQ

Consider the following C function definition. int fX(char *a) { char *b = a; while(*b) b++; return b - a; } Which of the following statements is/are TRUE?

Programming Languages/MSQ/answer key/explanation
2024 PYQ

What is the output of the following C program? #include <studio.h> int main() { double a[2]={20.0, 25.0}, *p, *q; p = a; q = p + 1; printf("%d,%d", (int)(q - p), (int)(*q - *p)); r...

Programming Languages/MCQ/answer key/explanation
2024 PYQ

Consider an array X that contains n positive integers. A subarray of X is defined to be a sequence of array locations with consecutive indices. The C code snippet given below has b...

Programming Languages/MCQ/answer key/explanation
2023 PYQ

The integer value printed by the ANSI-C program given below is ___________. #include<stdio.h> int funcp(){ static int x = 1; x++ ; return x; } int main(){ int x,y; x = funcp(); y =...

Programming Languages/NAT/explanation
2023 PYQ

Consider the following program: int main ( ) { f1( ); f2(2); f3( ); return (0); } int f1( ) { return (1); } int f2 (int X) { f3( ); if (X==1) return f1 ( ); else return (X*f2(X$$-$...

Programming Languages/MCQ/answer key/explanation
2022 PYQ

What is printed by the following ANSI C program? #include <stdio.h> int main(int argc, char *argv[ ]) { int x = 1, z[2] = {10, 11}; int *p = NULL; p = &x; *p = 10; p = &z[1]; *(&z[...

Programming Languages/MCQ/answer key
2022 PYQ

What is printed by the following ANSI C program? #include <stdio.h> int main(int argc, char *argv[ ]) { int a[3][3][3] = {{1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14, 15, 16,...

Programming Languages/MCQ/answer key/explanation
2021 PYQ

Consider the following ANSI C program. #include <stdio.h> int main( ) { int i, j, count; count = 0; i = 0; for (j = -3; j = 0) && (i++)) count = count + j; } count = count + i; pri...

Programming Languages/MCQ/answer key/explanation
2021 PYQ

Consider the following ANSI C program #include <stdio.h> int foo(int x, int y, int q) { if ((x <= 0 && (y <= 0)) return q; if (x <= 0) return foo(x, y - q, q); if (y <= 0) return f...

Programming Languages/NAT/explanation
2021 PYQ

Consider the following ANSI C program. #include<stdio.h> int main(){ int arr[4][5]; int i, j; for(i =0; i<4; i++){ for (j =0; j<5; j++){ arr [i][j] = 10*i + j; } } print("%d", *(ar...

Programming Languages/MCQ/answer key/explanation
2021 PYQ

Consider the following ANSI C function: int SimpleFunction (int y[], int n, int x) { int total = y[0], loopIndex; for (loopIndex = 1; loopIndex <= n - 1; loopIndex ++ ) total = x *...

Programming Languages/NAT/explanation
2021 PYQ

Consider the following ANSI C function: int SomeFunction (int x, int y) { if ( (x == 1) I I (y == 1)) return 1; if (x == y) return x; if (x > y) return SomeFunction(x - y, y); if (...

Programming Languages/NAT/explanation
2021 PYQ

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 =...

Programming Languages/MCQ/answer key/explanation
2020 PYQ

Consider the following C functions. int tob(int b, int* arr) { int i; for (i=0; b>0; i++) { if (b%2) arr[i] = 1; else arr[i]=0; b = b/2; } return (i); } ____________________ int pp...

Programming Languages/NAT/explanation
2020 PYQ

Consider the following C functions. int fun1 (int n) { static int i = 0; if (n > 0) { ++i; fun1(n-1); } return (i); } ___________________ int fun2 (int n) { static int i = 0; if (n...

Programming Languages/NAT/explanation
2019 PYQ

Consider the following C program : #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 wil...

Programming Languages/NAT/explanation
2019 PYQ

Consider the following C program: #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...

Programming Languages/NAT/explanation
2019 PYQ

Consider the following C function. void convert(int n){ if(n < 0) printf("%d",n); else { convert(n/2); printf("%d",n%2); } } Which one of the following will happen when the functio...

Programming Languages/MCQ/answer key/explanation
2019 PYQ

Consider the following C program : #include<stdio.h> int r() { static int num=7; return num--; } int main() { for(r();r();r()) printf("%od ",r()); return 0; } Which one of the foll...

Programming Languages/MCQ/answer key/explanation
2019 PYQ

Consider the following C program : #include <stdio.h> int main(){ float sum = 0.0, j = 1.0, i = 2.0; while (i/j > 0.0625){ j = j + j; sum = sum + i/j; printf("%f\n", sum); } return...

Programming Languages/NAT/explanation
2019 PYQ

Consider the following C program: #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)...

Programming Languages/NAT/explanation
2018 PYQ

Consider the following C program: #include < stdio.h > int counter = 0; int calc (int a, int b) { int c; counter++; if (b==3) return (a*a*a); else { c = calc(a, b/3); return (c*c*c...

Programming Languages/NAT
2018 PYQ

Consider the following C code. Assume that unsigned long int type length is 64 bits. unsigned long int fun(unsigned long int n){ unsigned long int i, j = 0, sum = 0; for (i = n; i...

Programming Languages/MCQ/answer key
2018 PYQ

Consider the following C program. #include< stdio.h > struct Ournode{ char x,y,z; }; int main(){ struct Ournode p = {'1', '0', 'a'+2}; struct Ournode *q = &p; printf ("%c, %c", *((...

Programming Languages/MCQ/answer key
2018 PYQ

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...

Programming Languages/MCQ/answer key
2016 PYQ

Consider the following C program. #include < stdio.h > void mystery(int *ptra, int *ptrb) { int *temp; temp = ptrb; ptrb = ptra; ptra = temp; } int main() { int a=2016, b=0, c=4, d...

Programming Languages/NAT
2016 PYQ

Consider the following C program void f(int, short); void main() { int i = 100; short s = 12; short *p = &s; __________ ; // call to f() } Which one of the following expressions, w...

Programming Languages/MCQ/answer key
2015 PYQ

Consider the following function written in the C programming language. void foo(char *a){ if ( *a && *a != ' '){ foo(a+1); putchar(*a); } } The output of the above function on inpu...

Programming Languages/MCQ/answer key
2015 PYQ

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...

Programming Languages/MCQ/answer key
2015 PYQ

The output of the following C program is__________. void f1(int a, int b) { int c; c=a; a=b; b=c; } void f2(int *a, int *b) { int c; c=*a; *a=*b; *b=c; } int main(){ int a=4, b=5,...

Programming Languages/NAT
2015 PYQ

Consider the following C program segment. #include < stdio.h > int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = ‘0’; printf("%s", s1); } What will be printed by the program?

Programming Languages/MCQ/answer key
2015 PYQ

Consider the following C function. int fun ( int n ) { int x = 1, k ; if ( n == 1) return x ; for( k = 1 ; k < n ; ++ k ) x = x + fun( k ) * fun( n - k ) ; return x ; } The return...

Programming Languages/NAT
2015 PYQ

Consider the C program below. #include < stdio.h > int *A, stkTop; int stkFunc(int opcode, int val) { static int size=0, stkTop=0; switch (opcode) { case -1: size = val; break; cas...

Programming Languages/NAT
2015 PYQ

Consider the following pseudo code, where x and y are positive integers. begin q := 0 r := x while r ≥ y do begin r := r - y q := q + 1 end end The post condition that needs to be...

Programming Languages/MCQ/answer key
2014 PYQ

Consider the following program in C language: #include < stdio.h > main() { int i; int *pi = &i; scanf("%d", pi); printf("%d\n", i + 5); } Which one of the following statements is...

Programming Languages/MCQ/answer key
2014 PYQ

Which one of the following is NOT performed during compilation?

Programming Languages/MCQ/answer key
2014 PYQ

Consider the function func shown below: int func(int num) { int count = 0; while(num) { count++; num >>= 1; } return (count); } The value returned by func(435) is _________.

Programming Languages/NAT
2014 PYQ

Let A be a square matrix size $$n \times n$$. Consider the following pseudocode. What is the expected output? C = 100; for i = 0 to n do for j = 1 to n do { Temp = A[ i ][ j ] + C...

Programming Languages/MCQ/answer key
2014 PYQ

Which of the following statements are CORRECT? 1) Static allocation of all data areas by a compiler makes it impossible to implement recursion. 2) Automatic garbage collection is e...

Programming Languages/MCQ/answer key
2014 PYQ

Suppose n and p are unsigned int variables in a C program. We wish to set p to $${}^n{C_3}$$. If n is large, which one of the following statements is most likely to set p correctly...

Programming Languages/MCQ/answer key
2014 PYQ

Consider the C function given below. int f(int j) { static int i = 50; int k; if (i == j) { printf("something"); k = f(i); return 0; } else return 0; } Which one of the following i...

Programming Languages/MCQ/answer key
2014 PYQ

Consider the following function double f (double x) { if ( abs (x * x – 3) < 0. 01) return x; else return f (x / 2 + 1.5/x); } Give a value q (to 2 decimals) such that f(q) will re...

Programming Languages/NAT
2013 PYQ

What is the return value of f (p, p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is p...

Programming Languages/MCQ/answer key
2012 PYQ

What will be the output of the following C program segment? Char inchar = 'A'; Switch ( inchar ) { case 'A' : printf ("Choice A\ n") ; case 'B' : case 'C' : printf (“Choice B”) ; c...

Programming Languages/MCQ/answer key
2012 PYQ

Consider the following C code segment. int a, b, c = 0; void prtFun(void); main( ) { static int a = 1; /* Line 1 */ prtFun(); a + = 1; prtFun(); printf("\n %d %d ", a, b); } void p...

Programming Languages/MCQ/answer key
2012 PYQ

Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted. Program main; Var . . . Procedure A1; Var . . . Ca...

Programming Languages/MCQ/answer key
2012 PYQ

Consider the following C code segment. int a, b, c = 0; void prtFun(void); main( ) { static int a = 1; /* Line 1 */ prtFun(); a + = 1; prtFun(); printf("\n %d %d ", a, b); } void p...

Programming Languages/MCQ/answer key
2011 PYQ

Consider the following recursive C function that takes two arguments: unsigned int foo (unsigned int n, unsigned int r) { if (n > 0) return((n % r) + foo(n/r, r)); else return 0; }...

Programming Languages/MCQ/answer key
2011 PYQ

Consider the following recursive C function that takes two arguments: unsigned int foo (unsigned int n, unsigned int r) { if (n > 0) return((n % r) + foo(n/r, r)); else return 0; }...

Programming Languages/MCQ/answer key
2011 PYQ

What does the following fragment of C-program print? char c[ ] = "GATE2011"; char *p = c; printf("%s", p + p[3] - p[1]);

Programming Languages/MCQ/answer key
2010 PYQ

Which languages necessarily need heap allocation in the runtime environment?

Programming Languages/MCQ/answer key
2010 PYQ

What does the following program print? #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...

Programming Languages/MCQ/answer key
2008 PYQ

Which of the following are true? I. A programming language which does not permit global variables of any kind and has no nesting of procedures/functions, but permits recursion can...

Programming Languages/STMT/answer key
2008 PYQ

What is printed by the following C program? #include < stdio.h > int f(int x, int *py, int **ppz) { int y, z; **ppz += 1; z = **ppz; *py += 2; y = *py; x += 3; return x + y + z; }...

Programming Languages/MCQ/answer key
2008 PYQ

Choose the correct option to fill ? 1 and ? 2 so that the program below prints an input string in reverse order. Assume that the input string is terminated by a newline character....

Programming Languages/MCQ/answer key
2007 PYQ

Consider the following C function: int f(int n) { static int r = 0; if(n <= 0) return 1; if(n>3) { r = n; return f(n-2)+2; } return f(n-1)+r; } What is the value of f(5)?

Programming Languages/MCQ/answer key
2006 PYQ

Consider this C code to swap two integers and these five statements: void swap(int *px, int *py) { *px = *px - *py; *py = *px + *py; *px = *py - *px; } S1: will generate a compilat...

Programming Languages/MCQ/answer key
2005 PYQ

What does the following C statement declare? int (*f)(int *);

Programming Languages/MCQ/answer key
2005 PYQ

Consider the following C program: void foo (int n, int sum) { int k = 0, j = 0; if(n==0) return; k=n%10; j = n /10; sum = sum + k; foo(j, sum); printf("%d",k); } int main () { int...

Programming Languages/MCQ/answer key
2005 PYQ

Consider the following C program: double foo(double); /* Line 1 */ int main () { double da, db; //input da db = foo(da); } double foo(double a){ return a; } The above code compiled...

Programming Languages/MCQ/answer key
2005 PYQ

Which one of the following are essential features of an object-oriented programming language? i) Abstraction and encapsulation ii) Strictly-typedness iii) Type-safe property couple...

Programming Languages/MCQ/answer key
2005 PYQ

A common property of logic programming languages and functional languages is:

Programming Languages/MCQ/answer key
2005 PYQ

An Abstract Data Type (ADT) is

Programming Languages/MCQ/answer key
2004 PYQ

Consider the following C program main ( ) { int x, y, m, n; scanf("%d %d", &x, &y); /* Assume x > 0 and y > 0 */ m=x; n=y; while(m!=n) { if(m>n) m=m-n; else n=n-m; } printf("%d", n...

Programming Languages/MCQ/answer key