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 26–30 of 54

Q26GATE 2015 (Session 1)2 marksMCQ−0.67 if wrong
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,2,3},{4,5,6},{7,8,9},{10,11,12}};
printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3);
}

Q27GATE 2015 (Session 3)1 markMCQ−0.33 if wrong
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?

Q28GATE 2015 (Session 3)2 marksNAT
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;
ptr++;
printf("%d%d", ptr-p,**ptr);
}
The output of the program is ______________.

Q29GATE 2014 (Session 1)1 markMCQ−0.33 if wrong
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 TRUE?

Q30GATE 2014 (Session 3)2 marksMCQ−0.67 if wrong
Consider the C function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending order.
int ProcessArray(int *listA, int x, int n)
{
   int i, j, k;
   i = 0;
   j = n-1;
   do {
          k = (i+j)/2;
          if (x <= listA[k])
               j = k-1;
          if (listA[k] <= x)
              i = k+1;
       }while (i <= j);
if (listA[k] == x)
     return(k);
else
    return -1;
} 
Which one of the following statements about the function ProcessArray is CORRECT?

Keep practising

Topics in Programming in C

All CS topics ›