Skip to main content

File Input Output — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on File Input Output — Part 2 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

Each call of va_arg . . . . . . . .

Question 2 of 40
★ FPSC ★ PPSC

setvbuf() and setbuf() function controls buffering for the stream.

Question 3 of 40
★ FPSC ★ PPSC

What will be the output of the following C code if following commands are used to run (considering myfile exists)? gcc -otest test.c ./test < myfile #include <stdio.h> int main() { char c = 'd'; putchar(c); }

Question 4 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #include <ctype.h> int main() { int i = 0; if (isspace(i)) printf("space\n"); else printf("not space\n"); return 0; }

Question 5 of 40
★ FPSC ★ PPSC

fputs() function writes a string to a file that only ends with a newline.

Question 6 of 40
★ FPSC ★ PPSC

. . . . . . . . removes the named file, so that a subsequent attempt to open it will fail.

Question 7 of 40
★ FPSC ★ PPSC

Escape sequences are prefixed with . . . . . . . .

Question 8 of 40
★ FPSC ★ PPSC

What is the default return-type of getchar()?

Question 9 of 40
★ FPSC ★ PPSC

Choose the correct description for control string %-+7.2f.

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #include <ctype.h> int main() { char c = 't'; printf("is :%c\n", tolower('A')); }

Question 11 of 40
★ FPSC ★ PPSC

ungetc() is used . . . . . . . .

Question 12 of 40
★ FPSC ★ PPSC

Which mathematical function among the following does NOT require int parameters?

Question 13 of 40
★ FPSC ★ PPSC

Which pre-defined function returns a pointer to the last occurence of a character in a string?

Question 14 of 40
★ FPSC ★ PPSC

Select the correct value of i from given options i=scanf("%d %d", &a, &b);

Question 15 of 40
★ FPSC ★ PPSC

What error will generate if the read and write parameters are not separated by commas?

Question 16 of 40
★ FPSC ★ PPSC

gets() and puts() operate on . . . . . . . .

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> int main() { char str[11] = "hello"; char *str1 = "world"; strcat(str, str1); printf("%s %d", str, str[10]); }

Question 18 of 40
★ FPSC ★ PPSC

Only . . . . . . . . character of pushback is guaranteed per file when ungetc is used.

Question 19 of 40
★ FPSC ★ PPSC

Which of the following statements about stdout and stderr are true?

Question 20 of 40
★ FPSC ★ PPSC

What is the meaning of the following C statement? printf(“%10s”, state);

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> int main() { short int i; scanf("%*d", &i); printf("%hd", i); return 0; }

Question 22 of 40
★ FPSC ★ PPSC

On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to.

Question 23 of 40
★ FPSC ★ PPSC

void * malloc(size_t n) returns?

Question 24 of 40
★ FPSC ★ PPSC

What does the following segment of C code do? fprintf(fp, "Copying!");

Question 25 of 40
★ FPSC ★ PPSC

Which of the following represents the function for scanf()?

Question 26 of 40
★ FPSC ★ PPSC

Which of the following can be used for random number generation?

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> int main() { char *s = "myworld"; int i = 9; printf("%*s", i, s); }

Question 28 of 40
★ FPSC ★ PPSC

What will be the output of the following C statement? fprintf(stderr, "error: could not open filen");

Question 29 of 40
★ FPSC ★ PPSC

Which among the following is the odd one out?

Question 30 of 40
★ FPSC ★ PPSC

The syntax of the scanf() is scanf("control string ", arg1,arg2,arg3,....,argn); the prototype of control string is

Question 31 of 40
★ FPSC ★ PPSC

Output justification such as decimal point, numerical sign, trailing zeros or octal are specified.

Question 32 of 40
★ FPSC ★ PPSC

function fabs defined math.h header file takes the argument of type integer.

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following C code considering user typed jkl? #include <stdio.h> int main() { char n[20]; fgets(n, 19, stdin); ungetc(n[0], stdin); printf("%s\n", n); return 0; }

Question 34 of 40
★ FPSC ★ PPSC

Which of the following is NOT a delimiter for an input in scanf?

Question 35 of 40
★ FPSC ★ PPSC

Which is true about isupper(c), where c is an int that can be represented as an unsigned? char or EOF.isupper(c) returns

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #include <math.h> void main() { int k = fabs(-87); printf("%d\n", k); }

Question 37 of 40
★ FPSC ★ PPSC

gets() function checks overflow run.

Question 38 of 40
★ FPSC ★ PPSC

In linux, apart from including math header file, the program is successfully executed by which of the following?

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> int main() { char i = '9'; if (isdigit(i)) printf("digit\n"); else printf("not digit\n"); return 0; }

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> #include <stdlib.h> int main() { FILE *fp = stdout; int n; fprintf(fp, "%d", 45); }

✓ 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 →