250+ TOP MCQs on Ungetc and Answers

’s Objective Questions and Answers on C helps Freshers preparing for Campus Interviews. Freshers’s should practice these questions continuously for 2-3 months, thereby ensuring a top position in campus interviews or fresher’s hiring programs.

Here is a listing of online C test questions on “Ungetc Function” along with answers, explanations and/or solutions:

1. Which of the following is the correct declaration for ungetc?
a) int ungetc(int c, FILE fp);
b) int ungetc(int *c, FILE fp);
c) int ungetc(int c, FILE *fp);
d) int ungetc(int *c, FILE *fp);
Answer: c
Clarification: None.

2. Which of the following cannot be used with ungetc()?
a) scanf
b) getc
c) getchar
d) printf
Answer: d
Clarification: None.

3. What does the ungetc function return for the following C expression?

ungetc(c, fp);//where declarations are int c and FILE *fp

a) It returns character c
b) It returns EOF for an error
c) Both returns character c and returns EOF for an error
d) Either returns character c or returns EOF for an error
Answer: d
Clarification: None.

4. What will be the output of the following C statement?

int ungetc(int c, FILE *fp)

a) Either c or EOF for an error
b) Nothing
c) fp
d) None of the mentioned
Answer: a
Clarification: None.

5. Only _____character of pushback is guaranteed per file when ungetc is used.
a) Two
b) One
c) Many
d) Zero
Answer: b
Clarification: None.

6. ungetc() may be used with ________
a) scanf
b) getc
c) getchar
d) all of the mentioned

Answer: d
Clarification: None.

7. What is the syntax of ungetc()?
a) void ungetc(int c, FILE *fp)
b) int ungetc(int c, FILE *fp)
c) int ungetc(String c, FILE *fp)
d) int getc(int c, FILE *fp)
Answer: b
Clarification: None.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top