C Quiz – 103 | Question 4

Which of the following functions from “stdio.h” can be used in place of printf()?

(A) fputs() with FILE stream as stdout.
(B) fprintf() with FILE stream as stdout.
(C) fwrite() with FILE stream as stdout.
(D) All of the above three – a, b and c.
(E) In “stdio.h”, there’s no other equivalent function of printf().

Answer: (B)

Explanation: Though fputs() and fwrite() can accept FILE stream stdout and can output the given string but the input string wouldn’t result in formatted (i.e. containing format specifiers) output. But fprintf() can be used for formatted output. That’s why fprintf(stdout,”=%d=”,a); and printf(“=%d=”,a); both are equivalent. The correct answer is B.

Quiz of this Question

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.