Topics

All Programming in C 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 marksEasy (estimate)

    GATE CS 2026 Set 2, Q.60

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

    Pointers, Arrays and Strings

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

  6. GATE CS 2025 Set 1NAT1 markEasy (estimate)

    GATE CS 2025 Set 1, Q.34

    #include <stdio.h> 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 __...

    Pointers, Arrays and Strings

  7. GATE CS 2025 Set 1NAT2 marksEasy (estimate)

    GATE CS 2025 Set 1, Q.61

    #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 main(){ in...

    Pointers, Arrays and Strings

  8. GATE CS 2025 Set 1NAT2 marksEasy (estimate)

    GATE CS 2025 Set 1, Q.63

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

    Data Types, Operators and Control Flow

  9. GATE CS 2025 Set 2MCQ1 markEasy (estimate)

    GATE CS 2025 Set 2, Q.19

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

    Pointers, Arrays and Strings

  10. GATE CS 2025 Set 2NAT1 markEasy (estimate)

    GATE CS 2025 Set 2, Q.33

    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)

    Data Types, Operators and Control Flow

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

    GATE CS 2025 Set 2, Q.62

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

    Pointers, Arrays and Strings

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

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

    GATE CS 2024 Set 1, Q.18

    Consider the following C program: #include <stdio.h> int main(){ int a = 6; int b = 0; while(a < 10) { a = a / 12 + 1; a += b;} printf("%d", a); return 0;} Which one of the foll...

    Data Types, Operators and Control Flow

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

  15. GATE CS 2024 Set 1MSQ2 marksEasy (estimate)

    GATE CS 2024 Set 1, Q.48

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

    Data Types, Operators and Control Flow

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

  17. GATE CS 2024 Set 2MSQ1 markEasy (estimate)

    GATE CS 2024 Set 2, Q.33

    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?

    Pointers, Arrays and Strings

  18. GATE CS 2024 Set 2MCQ2 marksEasy (estimate)

    GATE CS 2024 Set 2, Q.36

    What is the output of the following C program? #include <stdio.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));...

    Pointers, Arrays and Strings

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

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

  21. GATE CS 2022MCQ1 markEasy (estimate)

    GATE CS 2022, Q.21

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

    Pointers, Arrays and Strings

  22. GATE CS 2022MCQ2 marksMedium (estimate)

    GATE CS 2022, Q.43

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

    Pointers, Arrays and Strings

  23. GATE CS 2022MCQ2 marksMedium (estimate)

    GATE CS 2022, Q.44

    What is printed by the following ANSI C program? #include<stdio.h> int main(int argc, char argv[]){ char a = 'P'; char b = 'x'; char c = (a & b) + ''; char d = (a | b) - '-';...

    Data Types, Operators and Control Flow

  24. GATE CS 2021 Set 1MCQ2 marksMedium (estimate)

    GATE CS 2021 Set 1, Q.47 (CS Q.37)

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

    Data Types, Operators and Control Flow

  25. GATE CS 2021 Set 1NAT2 marksEasy (estimate)

    GATE CS 2021 Set 1, Q.58 (CS Q.48)

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

    Data Types, Operators and Control Flow

  26. GATE CS 2021 Set 2MCQ1 markMedium (estimate)

    GATE CS 2021 Set 2, Q.20 (CS Q.10)

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

    Pointers, Arrays and Strings

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

  28. GATE CS 2021 Set 2MCQ2 marksMedium (estimate)

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

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

    Pointers, Arrays and Strings

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

  30. GATE CS 2020NAT1 markEasy (estimate)

    GATE CS 2020, Q.32 (CS Q.22)

    Consider the following C program. #include <stdio.h> int main() { int a[4][5] = {{ {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20} }}; printf(...

    Pointers, Arrays and Strings · Pointers, Arrays and Strings

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

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

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

  34. GATE CS 2019NAT1 markEasy (estimate)

    GATE CS 2019, Q.34 (CS Q.24)

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

    Pointers, Arrays and Strings

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

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

  37. GATE CS 2019NAT2 marksEasy (estimate)

    GATE CS 2019, Q.62 (CS Q.52)

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

    Data Types, Operators and Control Flow

  38. GATE CS 2019NAT2 marksEasy (estimate)

    GATE CS 2019, Q.63 (CS Q.53)

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

    Pointers, Arrays and Strings

  39. GATE CS 2018MCQ1 markEasy (estimate)

    GATE CS 2018, Q.12 (CS Q.2)

    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", *(...

    Pointers, Arrays and Strings

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

  41. GATE CS 2018MCQ2 marksEasy (estimate)

    GATE CS 2018, Q.39 (CS Q.29)

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

    Pointers, Arrays and Strings

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

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

  44. GATE CS 2017 Set 1MCQ1 markMedium (estimate)

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

    Consider the C code fragment given below. typedef struct node { int data; struct node* next; } node; void join(node* m, node* n) { node* p = n; while (p->next != NULL) { p = p->...

    Pointers, Arrays and Strings · Arrays and Linked Lists

  45. GATE CS 2017 Set 1MCQ1 markMedium (estimate)

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

    Consider the following C code: #include <stdio.h> #include <stdlib.h> int *assignval(int *x, int val) { *x = val; return x; } void main() { int *x = malloc(sizeof(int)); if (NUL...

    Structures, Unions and Dynamic Memory Allocation · Pointers, Arrays and Strings

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

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

  48. GATE CS 2017 Set 1NAT2 marksEasy (estimate)

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

    Consider the following C program. #include <stdio.h> #include <string.h> void printlength(char *s, char *t) { unsigned int c = 0; int len = ((strlen(s) - strlen(t)) > c) ? strle...

    Data Types, Operators and Control Flow

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

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

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

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

    Consider the following function implemented in C: void printxy(int x, int y) { int *ptr; x = 0; ptr = &x; y = *ptr; *ptr = 1; printf("%d, %d", x, y); } The output of in...

    Pointers, Arrays and Strings

  52. GATE CS 2017 Set 2MCQ2 marksMedium (estimate)

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

    Consider the C program fragment below which is meant to divide by using repeated subtractions. The variables and are all unsigned int. while (r >= y...

    Data Types, Operators and Control Flow

  53. GATE CS 2017 Set 2NAT2 marksMedium (estimate)

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

    Consider the following snippet of a C program. Assume that swap(&x, &y) exchanges the contents of x and y. int main() { int array[] = {3, 5, 1, 4, 6, 2}; int done = 0...

    Pointers, Arrays and Strings · Searching and Sorting Algorithms

  54. GATE CS 2017 Set 2NAT2 marksEasy (estimate)

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

    Consider the following C program. #include <stdio.h> int main() { int m = 10; int n, n1; n = ++m; n1 = m++; n--; --n1; n -= n1; printf("%d", n); return 0; } The output...

    Data Types, Operators and Control Flow

  55. GATE CS 2017 Set 2NAT2 marksMedium (estimate)

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

    Consider the following C program. #include <stdio.h> #include <string.h> int main() { char* c = "GATECSIT2017"; char* p = c; printf("%d", (int) strlen(c + 2[p] - 6[p] - 1))...

    Pointers, Arrays and Strings

  56. GATE CS 2016 Set 1MCQ1 markEasy (estimate)

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

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

    Pointers, Arrays and Strings

  57. GATE CS 2016 Set 1NAT1 markEasy (estimate)

    GATE CS 2016 Set 1, Q.25 (CS Q.15)

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

    Pointers, Arrays and Strings

  58. GATE CS 2016 Set 1MCQ2 marksEasy (estimate)

    GATE CS 2016 Set 1, Q.44 (CS Q.34)

    The following function computes the maximum value contained in an integer array p[] of size (). int max(int *p, int n) { int a = 0, b = n - 1; while (_______...

    Pointers, Arrays and Strings

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

  60. GATE CS 2016 Set 1NAT2 marksMedium (estimate)

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

    The attributes of three arithmetic operators in some programming language are given below. Operator Precedence Associativity Arity + High Left Binary - Medium Right Binary * Low...

    Data Types, Operators and Control Flow

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

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

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

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

  65. GATE CS 2015 Set 1NAT1 markEasy (estimate)

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

    The output of the following C program is _____. #include <stdio.h> 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; *...

    Pointers, Arrays and Strings

  66. GATE CS 2015 Set 1MCQ2 marksEasy (estimate)

    GATE CS 2015 Set 1, Q.43 (CS Q.33)

    Consider the following pseudo code, where and are positive integers: begin q := 0 r := x while r >= y do begin r := r - y q := q + 1 end end The post conditi...

    Data Types, Operators and Control Flow

  67. GATE CS 2015 Set 1MCQ2 marksMedium (estimate)

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

    What is the output of the following C code? Assume that the address of x is (in decimal) and an integer requires four bytes of memory. #include <stdio.h> int main(...

    Pointers, Arrays and Strings

  68. GATE CS 2015 Set 1NAT2 marksMedium (estimate)Not in current syllabus

    GATE CS 2015 Set 1, Q.52 (CS Q.42)

    Consider the following C program segment. while (first <= last) { if (array[middle] < search) first = middle + 1; else if (array[middle] == search) found = TRUE; else last = mid...

    Data Types, Operators and Control Flow

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

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

  71. GATE CS 2015 Set 2MCQ1 markEasy (estimate)

    GATE CS 2015 Set 2, Q.25 (CS Q.15)

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

    Pointers, Arrays and Strings

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

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

  74. GATE CS 2015 Set 3MCQ1 markEasy (estimate)

    GATE CS 2015 Set 3, Q.17 (CS Q.7)

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

    Pointers, Arrays and Strings

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

    GATE CS 2015 Set 3, Q.36 (CS Q.26)

    Consider the following C program. #include <stdio.h> int main() { static int a[] = {10, 20, 30, 40, 50}; static int *p[] = {a, a + 3, a + 4, a + 1, a + 2}; int **ptr = p; p...

    Pointers, Arrays and Strings

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

    GATE CS 2015 Set 3, Q.40 (CS Q.30)

    Consider the following two C code segments. and are one and two dimensional arrays of size and respectively, where . Assume that in both...

    Pointers, Arrays and Strings · Memory Hierarchy: Cache, Main Memory and Secondary Storage

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

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

    GATE CS 2015 Set 3, Q.58 (CS Q.48)

    Consider the following C program: #include <stdio.h> int main() { int i, j, k = 0; j = 2 * 3 / 4 + 2.0 / 5 + 8 / 5; k -= --j; for (i = 0; i < 5; i++) { switch (i + k) { cas...

    Data Types, Operators and Control Flow

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

  80. GATE CS 2014 Set 1MCQ1 markEasy (estimate)

    GATE CS 2014 Set 1, Q.20 (CS Q.10)

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

    Pointers, Arrays and Strings

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

  82. GATE CS 2014 Set 1MCQ2 marksMedium (estimate)

    GATE CS 2014 Set 1, Q.51 (CS Q.41)

    Consider the following C function in which size is the number of elements in the array E: int MyX(int *E, unsigned int size) { int Y = 0; int Z; int i, j, k; for(i = 0; i <...

    Data Types, Operators and Control Flow

  83. GATE CS 2014 Set 2NAT1 markEasy (estimate)

    GATE CS 2014 Set 2, Q.20 (CS Q.10)

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

    Data Types, Operators and Control Flow

  84. GATE CS 2014 Set 2MCQ1 markMedium (estimate)

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

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

    Data Types, Operators and Control Flow

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

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

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

  88. GATE CS 2014 Set 3MCQ1 markMedium (estimate)

    GATE CS 2014 Set 3, Q.20 (CS Q.10)

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

    Pointers, Arrays and Strings

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

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

  91. GATE CS 2013MCQ2 marksMedium (estimate)

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

    Consider the following function: int unknown(int n){ int i, j, k=0; for (i=n/2; i<=n; i++) for (j=2; j<=n; j=j*2) k = k + n/2; return (k); } The return value of the fun...

    Data Types, Operators and Control Flow

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

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

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

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

    The tester now tests the program on all input strings of length five consisting of characters 'a', 'b', 'c', 'd' and 'e' with duplicates allowed. If the tester carries out this...

    Data Types, Operators and Control Flow

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

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

    If array A is made to hold the string "abcde", which of the above four test cases will be successful in exposing the flaw in this procedure?

    Data Types, Operators and Control Flow

  96. GATE CS 2012MCQ1 markMedium (estimate)

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

    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 ("Choic...

    Data Types, Operators and Control Flow

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

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

  99. GATE CS 2011MCQ1 markEasy (estimate)Not in current syllabus

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

    Which one of the following is NOT desired in a good Software Requirement Specifications (SRS) document?

    Data Types, Operators and Control Flow

  100. GATE CS 2011MCQ1 markEasy (estimate)

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

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

    Pointers, Arrays and Strings

  101. GATE CS 2011MCQ2 marksMedium (estimate)Not in current syllabus

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

    The following is the comment written for a C function. /* This function computes the roots of a quadratic equation a.x^2 + b.x + c = 0. The function stores two real roots i...

    Data Types, Operators and Control Flow

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

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