C Programming questions

Q21

GATE CS 2022 CSC ProgrammingMCQ1 mark−1/3 if wrong
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[0] + 1) += 3;
  printf("%d, %d, %d\n", x, z[0], z[1]);
  return 0;
}
Show answer without attempting

Answer: D

Q43

GATE CS 2022 CSC ProgrammingMCQ2 marks−2/3 if wrong
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, 17, 18},
   {19, 20, 21, 22, 23, 24, 25, 26, 27}};
  int i = 0, j = 0, k = 0;
  for( i = 0; i < 3; i++ ){
    for(k = 0; k < 3; k++ )
      printf("%d ", a[i][j][k]);
    printf("\n");
  }
  return 0;
}
Show answer without attempting

Answer: A

Q44

GATE CS 2022 CSC ProgrammingMCQ2 marks−2/3 if wrong
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) - '-';
  char e = (a ^ b) + '+';
  printf("%c %c %c\n", c, d, e);
  return 0;
}
ASCII encoding for relevant characters is given below
Question figure
Show answer without attempting

Answer: A

0/30 correct0 marks

Related topics in Programming and Data Structures