Array and Pointer: GATE CS Previous Year Questions

Array and Pointer · Programming in C

54 questions · asked in 22 of 27 years (2000–2026)

MCQ 39 · MSQ 1 · NAT 141-mark 34 · 2-mark 20

2000Questions per year2026

Questions 31–35 of 54

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

Q32GATE 20101 markMCQ−0.33 if wrong
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 0;
} 

Q33GATE 20082 marksMCQ−0.67 if wrong
C program is given below:
 #include <stdio.h>
int main ()
{
        int i, j;
        char a [2] [3] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};
        char b [3] [2];
        char *p = *b;
        for (i = 0; i < 2; i++) {
              for (j = 0; j < 3; j++) {
              *(p + 2*j + i) = a [i] [j];
              }
        }
}

What should be the contents of the array b at the end of the program?

Q34GATE 20082 marksMCQ−0.67 if wrong
Consider the C program given below. What does it print?
 #include <stdio.h>
int main ()
{
        int i, j;
        int a [8] = {1, 2, 3, 4, 5, 6, 7, 8};
        for(i = 0; i < 3; i++) {
             a[i] = a[i] + 1;
             i++;
        }
        i--;
        for (j = 7; j > 4; j--) {
              int i = j/2;
              a[i] = a[i] - 1;
        }
        printf ("%d, %d", i, a[i]);
}

Q35GATE 20082 marksMCQ−0.67 if wrong
What is the output printed by the following C code?
 #include <stdio.h>
int main ()
{
    char a [6] = "world";
    int i, j;
    for (i = 0, j = 5; i < j; a [i++] = a [j--]);
    printf ("%s\n", a);
}

Keep practising

Topics in Programming in C

All CS topics ›