Question 97Asked in BEL PE Computer Science, 20 Dec 2025 (5:00 PM)

Analyse the following C program and predict its output. int main() {

Analyse the following C program and predict its output. #include <stdio.h> int main() { FILE *fp; if ((fp = fopen("temp.txt", "r")) == NULL) printf("Error"); else fclose(fp); fclose(fp); return 0; }
  1. ACloses file safely twice
  2. BCompilation error
  3. CPrints 'Error'
  4. DUndefined behavior
Show answerHide answer

Correct answer: (D) Undefined behavior

From BEL PE Computer Science PYQ, 20 Dec 2025 (5:00 PM)

This is question 97 of BEL PE Computer Science PYQ, 20 Dec 2025 (5:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.