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.
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.
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.

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!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter

Check his free tutorial videos on Advanced C Programming. Join his Sanfoundry-Classes telegram channel for all videos and queries on Programming, Data-Structures, Kernel, Personality development and Mentoring.