GATE CS 2026, set 2 · Question 19 · Programming and Data Structures · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer
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?
- (A) Only P1 will compile without any error
- (B) Only P2 will compile without any error
- (C) Only P3 will compile without any error
- (D) All three programs P1, P2, and P3 will compile without any error
Answer
Answer (A)
Answer from the official GATE CS 2026 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes