Which of the following is an unformatted input function in C?

29 views
  • printf()
  • scanf()
  • gets() (Correct Answer)
  • puts()

Explanation

The correct answer is: C. gets() Explanation: In C programming, input and output functions can be broadly categorized into formatted and unformatted functions. Formatted input/output functions: These allow the specification of data types and formats, such as scanf() and printf(). Unformatted input/output functions: These deal with raw input or output, without format specifiers. Why gets() is unformatted: gets() reads an entire line of input (until a newline character) as a string, without requiring any format specifiers. It stores the input directly into a character array (string). scanf(), on the other hand, requires format specifiers to interpret the input correctly, making it a formatted input function. Other Options: A. printf(): Formatted output function. B. scanf(): Formatted input function. D. puts(): Unformatted output function (writes a string to the output followed by a newline). Thus, gets() is the correct answer as an unformatted input function. However, note that gets() is considered unsafe and has been deprecated in modern C standards due to the risk of buffer overflow.

Comments (0)

No comments yet. Be the first to comment!

Want to practice more?

Explore thousands of MCQs across every exam category on Exams Nepal.

Find More MCQs