Questions

  1. GATE CS 2026 Set 1NAT1 markEasy (estimate)

    GATE CS 2026 Set 1, Q.34

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

    Functions, Recursion, Scope and Storage Classes

  2. GATE CS 2026 Set 1NAT2 marksMedium (estimate)

    GATE CS 2026 Set 1, Q.61

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

    Functions, Recursion, Scope and Storage Classes

  3. GATE CS 2026 Set 2MCQ1 markEasy (estimate)

    GATE CS 2026 Set 2, Q.19

    Consider the following three ANSI-C programs, P1, P2, and P3. /* P1 / #include <stdio.h> int a=5; int main(){ int a=7; return(0); } / P2 */ #include <stdio.h> int main(){ int...

    Functions, Recursion, Scope and Storage Classes

  4. GATE CS 2026 Set 2NAT2 marksMedium (estimate)

    GATE CS 2026 Set 2, Q.61

    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(func(start...

    Functions, Recursion, Scope and Storage Classes

  5. GATE CS 2025 Set 2NAT2 marksEasy (estimate)

    GATE CS 2025 Set 2, Q.63

    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<3; n++) sum += g...

    Functions, Recursion, Scope and Storage Classes

  6. GATE CS 2024 Set 1MCQ1 markEasy (estimate)

    GATE CS 2024 Set 1, Q.19

    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);} Assume...

    Functions, Recursion, Scope and Storage Classes

  7. GATE CS 2024 Set 2MCQ1 markEasy (estimate)

    GATE CS 2024 Set 2, Q.13

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

    Functions, Recursion, Scope and Storage Classes

  8. GATE CS 2023NAT1 markEasy (estimate)

    GATE CS 2023, Q.35

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

    Functions, Recursion, Scope and Storage Classes

  9. GATE CS 2023MCQ2 marksMedium (estimate)

    GATE CS 2023, Q.36

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

    Functions, Recursion, Scope and Storage Classes

  10. GATE CS 2023MCQ2 marksEasy (estimate)

    GATE CS 2023, Q.47

    Consider the C function foo and the binary tree shown. Binary tree with root 10, left child 5 (with left child 3 and right child 8), and right child 11 (with right child 13). ty...

    Binary Trees, Binary Search Trees and Balanced Trees · Functions, Recursion, Scope and Storage Classes

  11. GATE CS 2021 Set 2NAT1 markEasy (estimate)

    GATE CS 2021 Set 2, Q.33 (CS Q.23)

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

    Functions, Recursion, Scope and Storage Classes

  12. GATE CS 2021 Set 2NAT2 marksEasy (estimate)

    GATE CS 2021 Set 2, Q.59 (CS Q.49)

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

    Functions, Recursion, Scope and Storage Classes

  13. GATE CS 2020NAT2 marksMedium (estimate)

    GATE CS 2020, Q.56 (CS Q.46)

    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 > 0) { i =...

    Functions, Recursion, Scope and Storage Classes · Functions, Recursion, Scope and Storage Classes

  14. GATE CS 2020NAT2 marksEasy (estimate)

    GATE CS 2020, Q.58 (CS Q.48)

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

    Pointers, Arrays and Strings · Functions, Recursion, Scope and Storage Classes

  15. GATE CS 2019NAT1 markEasy (estimate)

    GATE CS 2019, Q.28 (CS Q.18)

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

    Functions, Recursion, Scope and Storage Classes

  16. GATE CS 2019MCQ2 marksMedium (estimate)

    GATE CS 2019, Q.36 (CS Q.26)

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

    Functions, Recursion, Scope and Storage Classes

  17. GATE CS 2019MCQ2 marksMedium (estimate)

    GATE CS 2019, Q.37 (CS Q.27)

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

    Functions, Recursion, Scope and Storage Classes

  18. GATE CS 2018NAT1 markEasy (estimate)

    GATE CS 2018, Q.31 (CS Q.21)

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

    Functions, Recursion, Scope and Storage Classes

  19. GATE CS 2018MCQ2 marksEasy (estimate)

    GATE CS 2018, Q.42 (CS Q.32)

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

    Functions, Recursion, Scope and Storage Classes

  20. GATE CS 2018NAT2 marksMedium (estimate)

    GATE CS 2018, Q.55 (CS Q.45)

    Consider the following program written in pseudo-code. Assume that x and y are integers. Count(x,y) { if (y != 1){ if (x != 1) { print("*"); Count(x/2, y); } else { y = y-1; Cou...

    Functions, Recursion, Scope and Storage Classes

  21. GATE CS 2017 Set 1MCQ2 marksMedium (estimate)

    GATE CS 2017 Set 1, Q.35 (CS Q.35)

    Consider the following two functions. void fun1(int n) { if (n == 0) return; printf("%d", n); fun2(n - 2); printf("%d", n); } void fun2(int n) { if (n == 0) return; printf("%d",...

    Functions, Recursion, Scope and Storage Classes

  22. GATE CS 2017 Set 1MCQ2 marksMedium (estimate)

    GATE CS 2017 Set 1, Q.36 (CS Q.36)

    Consider the C functions foo and bar given below: int foo(int val) { int x = 0; while (val > 0) { x = x + foo(val--); } return val; } int bar(int val) { int x = 0; while (val >...

    Functions, Recursion, Scope and Storage Classes

  23. GATE CS 2017 Set 1NAT2 marksMedium (estimate)

    GATE CS 2017 Set 1, Q.55 (CS Q.55)

    The output of executing the following C program is ______. #include <stdio.h> int total(int v) { static int count = 0; while (v) { count += v & 1; v >>= 1; } return count; } voi...

    Functions, Recursion, Scope and Storage Classes · Data Types, Operators and Control Flow

  24. GATE CS 2017 Set 2MCQ1 markEasy (estimate)

    GATE CS 2017 Set 2, Q.2 (CS Q.2)

    Match the following: | Item | Description | | :--- | :--- | | (P) static char var; | (i) Sequence of memory locations to store addresses | | (Q) m = malloc(10); m = NULL; |...

    Functions, Recursion, Scope and Storage Classes · Structures, Unions and Dynamic Memory Allocation

  25. GATE CS 2016 Set 1MCQ2 marksMedium (estimate)

    GATE CS 2016 Set 1, Q.45 (CS Q.35)

    What will be the output of the following C program? #include <stdio.h> void count(int n) { static int d = 1; printf("%d ", n); printf("%d ", d); d++; if (n > 1) count(n - 1...

    Functions, Recursion, Scope and Storage Classes

  26. GATE CS 2016 Set 2NAT1 markEasy (estimate)

    GATE CS 2016 Set 2, Q.22 (CS Q.12)

    The value printed by the following program is ________. void f(int* p, int m){ m = m + 5; *p = *p + m; return; } void main(){ int i=5, j=10; f(&i, j); printf("%d", i+j); }

    Functions, Recursion, Scope and Storage Classes

  27. GATE CS 2016 Set 2MCQ2 marksMedium (estimate)

    GATE CS 2016 Set 2, Q.45 (CS Q.35)

    The following function computes for positive integers and . int exp(int X, int Y) { int res = 1, a = X, b = Y; while ( b != 0 ){ if ( b%2 == 0) { a = a*a; b = b/2;...

    Functions, Recursion, Scope and Storage Classes

  28. GATE CS 2016 Set 2NAT2 marksEasy (estimate)

    GATE CS 2016 Set 2, Q.47 (CS Q.37)

    Consider the following program: int f(int *p, int n) { if (n <= 1) return 0; else return max(f(p+1,n-1),p[0]-p[1]); } int main() { int a[] = {3,5,2,6,4}; printf("%d", f(a,5)); }...

    Functions, Recursion, Scope and Storage Classes

  29. GATE CS 2015 Set 1MCQ1 markEasy (estimate)Not in current syllabus

    GATE CS 2015 Set 1, Q.11 (CS Q.1)

    Match the following: | | Testing Technique | | Testing Category | | :--- | :--- | :--- | :--- | | (P) | Condition coverage | (i) | Black-box testing | | (Q) | Equivalence class...

    Functions, Recursion, Scope and Storage Classes

  30. GATE CS 2015 Set 2MCQ1 markEasy (estimate)Not in current syllabus

    GATE CS 2015 Set 2, Q.14 (CS Q.4)

    A software requirements specification (SRS) document should avoid discussing which one of the following?

    Functions, Recursion, Scope and Storage Classes

  31. GATE CS 2015 Set 2NAT1 markMedium (estimate)

    GATE CS 2015 Set 2, Q.21 (CS Q.11)

    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 value of fun(5) is _____.

    Functions, Recursion, Scope and Storage Classes

  32. GATE CS 2015 Set 2NAT2 marksMedium (estimate)

    GATE CS 2015 Set 2, Q.48 (CS Q.38)

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

    Functions, Recursion, Scope and Storage Classes

  33. GATE CS 2015 Set 2MCQ2 marksEasy (estimate)

    GATE CS 2015 Set 2, Q.53 (CS Q.43)

    Which one of the following assertions concerning code inspection and code walkthrough is true?

    Functions, Recursion, Scope and Storage Classes

  34. GATE CS 2015 Set 3MCQ2 marksMedium (estimate)

    GATE CS 2015 Set 3, Q.49 (CS Q.39)

    Consider the following recursive C function. void get(int n) { if (n < 1) return; get(n - 1); get(n - 3); printf("%d", n); } If get(6) function is being called in…

    Functions, Recursion, Scope and Storage Classes

  35. GATE CS 2015 Set 3NAT2 marksMedium (estimate)

    GATE CS 2015 Set 3, Q.64 (CS Q.54)

    Consider the following C program. #include <stdio.h> int f1(void); int f2(void); int f3(void); int x = 10; int main() { int x = 1; x += f1() + f2() + f3() + f2(); printf("%...

    Functions, Recursion, Scope and Storage Classes

  36. GATE CS 2014 Set 1MCQ1 markEasy (estimate)Not in current syllabus

    GATE CS 2014 Set 1, Q.28 (CS Q.18)

    Match the following: 1) Waterfall model: a) Specifications can be developed incrementally 2) Evolutionary model: b) Requirements compromises are inevitable 3) Component-based so...

    Functions, Recursion, Scope and Storage Classes

  37. GATE CS 2014 Set 2MCQ1 markEasy (estimate)Not in current syllabus

    GATE CS 2014 Set 2, Q.29 (CS Q.19)

    Which one of the following is TRUE?

    Functions, Recursion, Scope and Storage Classes

  38. GATE CS 2014 Set 2NAT2 marksEasy (estimate)

    GATE CS 2014 Set 2, Q.50 (CS Q.40)

    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 (to 2 decimals) such that ...

    Functions, Recursion, Scope and Storage Classes

  39. GATE CS 2014 Set 2MCQ2 marksEasy (estimate)

    GATE CS 2014 Set 2, Q.52 (CS Q.42)

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

    Functions, Recursion, Scope and Storage Classes

  40. GATE CS 2014 Set 3MCQ1 markEasy (estimate)Not in current syllabus

    GATE CS 2014 Set 3, Q.29 (CS Q.19)

    In the context of modular software design, which one of the following combinations is desirable?

    Functions, Recursion, Scope and Storage Classes

  41. GATE CS 2013MCQ1 markEasy (estimate)Not in current syllabus

    GATE CS 2013, Q.11 (CS Q.11)

    Match the problem domains in GROUP I with the solution technologies in GROUP II. GROUP I: (P) Service oriented computing (Q) Heterogeneous communicating systems (R) Information...

    Functions, Recursion, Scope and Storage Classes

  42. GATE CS 2013MCQ2 marksMedium (estimate)Not in current syllabus

    GATE CS 2013, Q.38 (CS Q.38)

    The following figure represents access graphs of two modules M1 and M2. The filled circles represent methods and the unfilled circles represent attributes. If method m is moved...

    Functions, Recursion, Scope and Storage Classes

  43. GATE CS 2013MCQ2 marksHard (estimate)

    GATE CS 2013, Q.42 (CS Q.42)

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

    Functions, Recursion, Scope and Storage Classes

  44. GATE CS 2012MCQ2 marksMedium (estimate)

    GATE CS 2012, Q.48 (CS Q.48)

    What output will be generated by the given code segment?

    Functions, Recursion, Scope and Storage Classes · Functions, Recursion, Scope and Storage Classes

  45. GATE CS 2012MCQ2 marksMedium (estimate)

    GATE CS 2012, Q.49 (CS Q.49)

    What output will be generated by the given code segment if: Line 1 is replaced by auto int a = 1; Line 2 is replaced by register int a = 2;

    Functions, Recursion, Scope and Storage Classes · Functions, Recursion, Scope and Storage Classes

  46. GATE CS 2011MCQ2 marksEasy (estimate)

    GATE CS 2011, Q.48 (CS Q.48)

    What is the return value of the function foo when it is called as foo(345, 10)?

    Functions, Recursion, Scope and Storage Classes

  47. GATE CS 2011MCQ2 marksEasy (estimate)

    GATE CS 2011, Q.49 (CS Q.49)

    What is the return value of the function foo when it is called as foo(513, 2)?

    Functions, Recursion, Scope and Storage Classes

Other topics of Programming in C