Questions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Other topics of Programming in C