This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Line Input & Output – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What is the size of array “line” used in fgets(line, maxline, *fp) function?
a) maxline – 1
b) maxline
c) maxline + 1
d) Size is dynamic
View Answer
Explanation: None.
2. What will be the output of the following C function when EOF returns?
int fputs(char *line, FILE *fp)
a) ‘�’ character of array line is encountered
b) ‘n’ character in array line is encountered
c) ‘t’ character in array line is encountered
d) When an error occurs
View Answer
Explanation: None.
3. Identify X library function for line input and output in the following C code?
#include <stdio.h>
int X(char *s, FILE *iop)
{
int c;
while (c = *s++)
putc(c, iop);
return ferror(iop) ? EOF : 0;
}
a) getc
b) putc
c) fgets
d) fputs
View Answer
Explanation: None.
4. Which function has a return type as char pointer?
a) getline
b) fputs
c) fgets
d) all of the mentioned
View Answer
Explanation: None.
5. Which of the following is the right declaration for fgets() inside the library?
a) int *fgets(char *line, int maxline, FILE *fp);
b) char *fgets(char *line, int maxline, FILE *fp);
c) char *fgets(char *line, FILE *fp);
d) int *fgets(char *line, FILE *fp);
View Answer
Explanation: None.
6. what is the return value of fputs()?
a) EOF if an error occurs
b) Non-negative if no error
c) EOF if an error occurs & Non-negative if no error
d) None of the mentioned
View Answer
Explanation: None.
7. gets() and puts() operate on ___________
a) stdin and stdout
b) files
c) stderr
d) nothing
View Answer
Explanation: None.
8. gets() does the following when it reads from stdin.
a) Deletes the ‘t’
b) Puts adds it.
c) Deletes the terminating ‘n’
d) Nothing
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Computer Science Books
- Apply for C Internship
- Practice BCA MCQs
- Apply for Computer Science Internship
- Practice Computer Science MCQs