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
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Each call of va_arg . . . . . . . .
Correct Answer: Option C — Returns one argument & Steps va_list variable to the next
Detailed Academic Explanation:
Returns one argument & Steps va_list variable to the next is the correct answer to “Each call of va_arg . . . . . . . .”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
setvbuf() and setbuf() function controls buffering for the stream.
Correct Answer: Option A — true
Detailed Academic Explanation:
true is the correct answer to “setvbuf() and setbuf() function controls buffering for the stream.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 3 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option C — d on the screen
Detailed Academic Explanation:
d on the screen is the correct answer to “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); }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 4 of 40
★ FPSC
★ PPSC
★ 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; }
Correct Answer: Option C — not space
Detailed Academic Explanation:
not space is the correct answer to “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; }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
fputs() function writes a string to a file that only ends with a newline.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “fputs() function writes a string to a file that only ends with a newline.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
. . . . . . . . removes the named file, so that a subsequent attempt to open it will fail.
Correct Answer: Option A — remove(const *filename)
Detailed Academic Explanation:
remove(const *filename) is the correct answer to “. . . . . . . . removes the named file, so that a subsequent attempt to open it will fail.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Escape sequences are prefixed with . . . . . . . .
Correct Answer: Option D — None of the mentioned
Detailed Academic Explanation:
None of the mentioned is the correct answer to “Escape sequences are prefixed with . . . . . . . .”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the default return-type of getchar()?
Correct Answer: Option B — int
Detailed Academic Explanation:
int is the correct answer to “What is the default return-type of getchar()”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the correct description for control string %-+7.2f.
Correct Answer: Option B — - means left justify, + means display the sign, 7 specifies the width and 2 specifies the precision
Detailed Academic Explanation:
- means left justify, + means display the sign, 7 specifies the width and 2 specifies the precision is the correct answer to “Choose the correct description for control string %-+7.2f.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 10 of 40
★ FPSC
★ PPSC
★ 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')); }
Correct Answer: Option B — Non-zero number
Detailed Academic Explanation:
Non-zero number is the correct answer to “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')); }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
ungetc() is used . . . . . . . .
Correct Answer: Option C — to push a character back to file
Detailed Academic Explanation:
to push a character back to file is the correct answer to “ungetc() is used . . . . . . . .”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which mathematical function among the following does NOT require int parameters?
Correct Answer: Option C — sqrt(x)
Detailed Academic Explanation:
sqrt(x) is the correct answer to “Which mathematical function among the following does NOT require int parameters”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which pre-defined function returns a pointer to the last occurence of a character in a string?
Correct Answer: Option B — strrchr(s, c)
Detailed Academic Explanation:
strrchr(s, c) is the correct answer to “Which pre-defined function returns a pointer to the last occurence of a character in a string”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Select the correct value of i from given options i=scanf("%d %d", &a, &b);
Correct Answer: Option B — 2
Detailed Academic Explanation:
2 is the correct answer to “Select the correct value of i from given options i=scanf("%d %d", &a, &b);”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What error will generate if the read and write parameters are not separated by commas?
Correct Answer: Option B — compile error
Detailed Academic Explanation:
compile error is the correct answer to “What error will generate if the read and write parameters are not separated by commas”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
gets() and puts() operate on . . . . . . . .
Correct Answer: Option A — stdin and stdout
Detailed Academic Explanation:
stdin and stdout is the correct answer to “gets() and puts() operate on . . . . . . . .”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 17 of 40
★ FPSC
★ PPSC
★ 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]); }
Correct Answer: Option A — helloworld 0
Detailed Academic Explanation:
helloworld 0 is the correct answer to “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]); }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Only . . . . . . . . character of pushback is guaranteed per file when ungetc is used.
Correct Answer: Option B — One
Detailed Academic Explanation:
One is the correct answer to “Only . . . . . . . . character of pushback is guaranteed per file when ungetc is used.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following statements about stdout and stderr are true?
Correct Answer: Option C — Both connected to screen by default
Detailed Academic Explanation:
Both connected to screen by default is the correct answer to “Which of the following statements about stdout and stderr are true”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the meaning of the following C statement? printf(“%10s”, state);
Correct Answer: Option B — Print empty spaces if the string state is less than 10 characters
Detailed Academic Explanation:
Print empty spaces if the string state is less than 10 characters is the correct answer to “What is the meaning of the following C statement? printf(“%10s”, state);”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 21 of 40
★ FPSC
★ PPSC
★ 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; }
Correct Answer: Option B — Somegarbage value
Detailed Academic Explanation:
Somegarbage value is the correct answer to “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; }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to.
Correct Answer: Option C — The same deallocated memory location
Detailed Academic Explanation:
The same deallocated memory location is the correct answer to “On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
void * malloc(size_t n) returns?
Correct Answer: Option A — Pointer to n bytes of uninitialized storage
Detailed Academic Explanation:
Pointer to n bytes of uninitialized storage is the correct answer to “void * malloc(size_t n) returns”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the following segment of C code do? fprintf(fp, "Copying!");
Correct Answer: Option A — It writes "Copying!" into the file pointed by fp
Detailed Academic Explanation:
It writes "Copying!" into the file pointed by fp is the correct answer to “What does the following segment of C code do? fprintf(fp, "Copying!");”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following represents the function for scanf()?
Correct Answer: Option B — int scanf(char *format, ...)
Detailed Academic Explanation:
int scanf(char *format, ...) is the correct answer to “Which of the following represents the function for scanf()”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following can be used for random number generation?
Correct Answer: Option A — random()
Detailed Academic Explanation:
random() is the correct answer to “Which of the following can be used for random number generation”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 27 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — myworld(note: spaces to the left of myworld)
Detailed Academic Explanation:
myworld(note: spaces to the left of myworld) is the correct answer to “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); }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C statement? fprintf(stderr, "error: could not open filen");
Correct Answer: Option A — The diagnostic output is directly displayed in the output
Detailed Academic Explanation:
The diagnostic output is directly displayed in the output is the correct answer to “What will be the output of the following C statement? fprintf(stderr, "error: could not open filen");”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which among the following is the odd one out?
Correct Answer: Option D — scanf
Detailed Academic Explanation:
scanf is the correct answer to “Which among the following is the odd one out”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The syntax of the scanf() is scanf("control string ", arg1,arg2,arg3,....,argn); the prototype of control string is
Correct Answer: Option A — [=%[width][modifiers]type=]
Detailed Academic Explanation:
[=%[width][modifiers]type=] is the correct answer to “The syntax of the scanf() is scanf("control string ", arg1,arg2,arg3,....,argn); the prototype of control string is”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Output justification such as decimal point, numerical sign, trailing zeros or octal are specified.
Correct Answer: Option B — flags
Detailed Academic Explanation:
flags is the correct answer to “Output justification such as decimal point, numerical sign, trailing zeros or octal are specified.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
function fabs defined math.h header file takes the argument of type integer.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “function fabs defined math.h header file takes the argument of type integer.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 33 of 40
★ FPSC
★ PPSC
★ 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; }
Correct Answer: Option A — jkl
Detailed Academic Explanation:
jkl is the correct answer to “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; }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is NOT a delimiter for an input in scanf?
Correct Answer: Option D — None of the mentioned
Detailed Academic Explanation:
None of the mentioned is the correct answer to “Which of the following is NOT a delimiter for an input in scanf”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 35 of 40
★ FPSC
★ PPSC
★ 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
Correct Answer: Option D — Both Non-zero if c is upper case & 0 if c is not upper case
Detailed Academic Explanation:
Both Non-zero if c is upper case & 0 if c is not upper case is the correct answer to “Which is true about isupper(c), where c is an int that can be represented as an unsigned? char or EOF.isupper(c) returns”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 36 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — 87
Detailed Academic Explanation:
87 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
gets() function checks overflow run.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “gets() function checks overflow run.”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In linux, apart from including math header file, the program is successfully executed by which of the following?
Correct Answer: Option D — cc -lm filename.c
Detailed Academic Explanation:
cc -lm filename.c is the correct answer to “In linux, apart from including math header file, the program is successfully executed by which of the following”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 39 of 40
★ FPSC
★ PPSC
★ 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; }
Correct Answer: Option A — digit
Detailed Academic Explanation:
digit is the correct answer to “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; }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
Question 40 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — 45
Detailed Academic Explanation:
45 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for File Input Output.
💡Key Conceptual Anchor:File Input Output
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡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.