GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2026 set2

GATE 2026 set2 · CS · MCQ · 1 mark · Programming and Data Structures › C Programming Fundamentals

GATE 2026 set2 Computer Science and Information Technology question: Consider the following three ANSI-C programs, P1, P2, and P3. P1: code P2: code P3: code…

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 a=5;
  int a=7;
  return(0);
}

P3:

#include <stdio.h>
int main(){
  int a=5;
  float a=7;
  return(0);
}

Which one of the following statements is true?

  1. (A)

    Only P1 will compile without any error

  2. (B)

    Only P2 will compile without any error

  3. (C)

    Only P3 will compile without any error

  4. (D)

    All three programs P1, P2, and P3 will compile without any error

Show answer

This question is in an all-India live mock that is open now. Its answer appears here when the mock closes.

Practise this question with exam-style marking