Explore topic-wise MCQs in C.

This section includes 24 Mcqs, each offering curated multiple-choice questions to sharpen your C knowledge and support exam preparation. Choose a topic below to get started.

1.

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

A. If it is not a macro, it may evaluate stream more than once
B. if it is amacro, it may not evaluate stream more than once
C. if it is a macro, it may evaluate stream more than once
D. no difference between fgetc() and getc()
Answer» D. no difference between fgetc() and getc()
2.

The______function reads atmost one less than the number of characters specified by size from the given stream and it is stored in the string str.

A. fget()
B. fgets()
C. fput()
D. fputs()
Answer» C. fput()
3.

The functions vprintf(), vfprintf(), and vsprintf() are not equivalent to the corresponding printf() functions except the variable argument list.

A. true
B. false
Answer» C.
4.

Which functions is declared in ?

A. fseek()
B. ftell()
C. ferror()
D. fsetpos()
Answer» D. fsetpos()
5.

Select the right explanation for the following C code snippet.

A. records the current position in stream in *s
B. sets the file position for stream in *s
C. positions stream at the position recorded in *s
D. reads from stream into the array ptrView Answer
Answer» B. sets the file position for stream in *s
6.

What does the following C code snippet mean?

A. reads the next input line into the array s
B. writes the line into the array s
C. reads the next input character into the array s
D. write a character into the arrayView Answer
Answer» B. writes the line into the array s
7.

what is the function of fputs()?

A. read a line from a file
B. read a character from a file
C. write a character to a file
D. write a line to a file
Answer» E.
8.

THE______FUNCTION_READS_ATMOST_ONE_LESS_THAN_THE_NUMBER_OF_CHARACTERS_SPECIFIED_BY_SIZE_FROM_THE_GIVEN_STREAM_AND_IT_IS_STORED_IN_THE_STRING_STR.?$

A. fget()
B. fgets()
C. fput()
D. fputs()
Answer» D. fputs()
9.

FWRITE()_CAN_BE_USED_ONLY_WITH_FILES_THAT_ARE_OPENED_IN_BINARY_MODE.?$

A. true
B. false
Answer» B. false
10.

The functions vprintf(), vfprintf(), and vsprintf() are not equivalent to the corresponding printf() functions except the variable argument list?

A. true
B. false
Answer» B. false
11.

EOF is an integer type defined in stdio. hand has a value ___________?

A. 1
B. 0
C. NULL
D. – 1
Answer» E.
12.

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

A. true
B. false
Answer» C.
13.

Choose the right statement for fscanf() and scanf()

A. fscanf() can read from standard input whereas scanf() specifies a stream from which to read
B. fscanf() can specifies a stream from which to read whereas scanf() can read only from standard input
C. fscanf() and scanf() has no difference in their functions
D. fscanf() and scanf() can read from specified stream
Answer» C. fscanf() and scanf() has no difference in their functions
14.

Which functions is declared in ?

A. fseek()
B. ftell()
C. ferror()
D. fsetpos()
Answer» C. ferror()
15.

What does tmpfile() returns when it could not create the file?

A. stream and NULL
B. only stream
C. only NULL
D. does not return anything
Answer» B. only stream
16.

records the current position in stream in *s

A. sets the file position for stream in *s
B. positions stream at the position recorded in *s
C. reads from stream into the array ptr
Answer» B. positions stream at the position recorded in *s
17.

What is the function of FILE *tmpfile(void)?

A. creates a temporary file of mode “wb+”
B. creates a temporary file of mode “wb”
C. creates a temporary file of mode ” w”
D. creates a temporary file of mode “w+”
Answer» B. creates a temporary file of mode ‚Äö√Ñ√∂‚àö√ë‚àö‚à´wb‚Äö√Ñ√∂‚àö√ë‚àöœÄ
18.

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

A. remove(const *filename)
B. remove(filename)
C. remove()
D. fclose(filename)
Answer» B. remove(filename)
19.

Which function will return the current file position for stream?

A. fgetpos()
B. fseek()
C. ftell()
D. fsetpos()
Answer» B. fseek()
20.

fflush(NULL) flushes all ____________

A. input streams
B. output streams
C. previous contents
D. appended text
Answer» C. previous contents
21.

reads the next input line into the array s

A. writes the line into the array s
B. reads the next input character into the array s
C. write a character into the array
Answer» D.
22.

If the mode includes b after the initial letter, what does it indicates?

A. text file
B. big text file
C. binary file
D. blueprint text
Answer» D. blueprint text
23.

What is the function of the mode ‘ w+’?$

A. create text file for writing, discard previous contents if any
B. create text file for update, discard previous contents if any
C. create text file for writing, do not discard previous contents if any
D. create text file for update, do not discard previous contents if any
Answer» C. create text file for writing, do not discard previous contents if any
24.

Which one of the following is correct syntax for opening a file.

A. FILE *fopen(const *filename, const char *mode)
B. FILE *fopen(const *filename)
C. FILE *open(const *filename, const char *mode)
D. FILE open(const*filename)
Answer» B. FILE *fopen(const *filename)