Skip to main content

File Input Output — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on File Input Output — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

How do you read a character from a file in C?

Question 2 of 40
★ FPSC ★ PPSC

The given statement FILE *fptr;

Question 3 of 40
★ FPSC ★ PPSC

What are the two predefined FILE pointers in C?

Question 4 of 40
★ FPSC ★ PPSC

In C, which library is used for file operations such as reading and writing files?

Question 5 of 40
★ FPSC ★ PPSC

Which function is used to open a file in C for writing?

Question 6 of 40
★ FPSC ★ PPSC

What does 'FILE' represent in C when working with files?

Question 7 of 40
★ FPSC ★ PPSC

How do you check if a file was opened successfully in C?

Question 8 of 40
★ FPSC ★ PPSC

Which function is used to write data to a file in C?

Question 9 of 40
★ FPSC ★ PPSC

What is the difference between 'r' and 'w' modes when opening a file in C?

Question 10 of 40
★ FPSC ★ PPSC

What is the purpose of the 'fprintf' function in C?

Question 11 of 40
★ FPSC ★ PPSC

Which function is used to close a file in C?

Question 12 of 40
★ FPSC ★ PPSC

In C, what is the function of the 'feof' function?

Question 13 of 40
★ FPSC ★ PPSC

Which function is used to move the file pointer to a specific position in a file?

Question 14 of 40
★ FPSC ★ PPSC

What is the purpose of the 'rewind' function in C?

Question 15 of 40
★ FPSC ★ PPSC

Which function is used to read a line of text from a file in C?

Question 16 of 40
★ FPSC ★ PPSC

What does the 'fread' function in C do?

Question 17 of 40
★ FPSC ★ PPSC

Which function is used to rename a file in C?

Question 18 of 40
★ FPSC ★ PPSC

In C, what does the 'feof' function return if the end of the file is reached?

Question 19 of 40
★ FPSC ★ PPSC

How do you check if a file exists in C?

Question 20 of 40
★ FPSC ★ PPSC

What is the purpose of the 'ftell' function in C?

Question 21 of 40
★ FPSC ★ PPSC

Which function is used to write a character to a file in C?

Question 22 of 40
★ FPSC ★ PPSC

What happens if you try to open a file in 'r' mode that doesn't exist in C?

Question 23 of 40
★ FPSC ★ PPSC

How do you read a string from a file in C?

Question 24 of 40
★ FPSC ★ PPSC

What does the 'remove' function in C do?

Question 25 of 40
★ FPSC ★ PPSC

In C, what is the purpose of the 'fflush' function?

Question 26 of 40
★ FPSC ★ PPSC

Which function is used to create a new directory in C?

Question 27 of 40
★ FPSC ★ PPSC

How do you write an integer to a file in C?

Question 28 of 40
★ FPSC ★ PPSC

What is the return value of 'putc' if it fails to write a character to a file in C?

Question 29 of 40
★ FPSC ★ PPSC

Which function is used to read and write data in binary mode in C?

Question 30 of 40
★ FPSC ★ PPSC

What is the purpose of the 'fileno' function in C?

Question 31 of 40
★ FPSC ★ PPSC

The function fprintf is used in the program ...........

Question 32 of 40
★ FPSC ★ PPSC

Which one of the following is valid for opening a read-only ASCII file?

Question 33 of 40
★ FPSC ★ PPSC

Choose the correct difference between getc() and fgetc().

Question 34 of 40
★ FPSC ★ PPSC

. . . . . . . . is an optional argument that gives the maximum number of characters to be read.

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct p { struct p *next; int x; }; int main() { struct p* p1 = malloc(sizeof(struct p)); p1->x = 1; p1->next = malloc(sizeof(struct p)); printf("%d\n", p1->next->x); return 0; }

Question 36 of 40
★ FPSC ★ PPSC

If the conversion characters of int d, i, o, u and x are preceded by h, it indicates?

Question 37 of 40
★ FPSC ★ PPSC

Which among the following mathematical function do not have a "double" return-type?

Question 38 of 40
★ FPSC ★ PPSC

Which of the following function compares 2 strings with case-insensitively?

Question 39 of 40
★ FPSC ★ PPSC

What is FILE reserved word?

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #include <math.h> int main() { unsigned int i = -1; printf("%f\n", fabs(i)); return 0; }

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →