C Programming Questions and Answers – Ungetc – 2

«
»

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Ungetc – 2”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

advertisement

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);
View Answer

Answer: c
Explanation: None.

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

Answer: d
Explanation: None.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
advertisement

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
View Answer

Answer: d
Explanation: None.
Take C Programming Mock Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
advertisement

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

advertisement
int ungetc(int c, FILE *fp)

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

Answer: a
Explanation: None.
advertisement

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

Answer: b
Explanation: None.

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

Answer: d
Explanation: 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)
View Answer

Answer: b
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.

advertisement
advertisement

Leave a Comment

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.