Knowee
Questions
Features
Study Tools

Which of the following function is more appropriate for reading in a multi-word string? ans. scanf() printf() gets() puts()

Question

Which of the following function is more appropriate for reading in a multi-word string?

  • ans.
    • scanf()
    • printf()
    • gets()
    • puts()
🧐 Not the exact question you are looking for?Go ask a question

Solution

The most appropriate function for reading in a multi-word string in C is gets().

Here's why:

  1. scanf(): This function reads the input from the user until it encounters a whitespace. So, it's not suitable for multi-word strings.

  2. printf(): This function is used to print the output, not to read the input.

  3. gets(): This function reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF. So, it's suitable for multi-word strings.

  4. puts(): This function is used to write a string to stdout up to but not including the null character. So, it's not used to read the input.

So, the answer is gets().

This problem has been solved

Similar Questions

Which of the following function is more appropriate for reading in a multi-word string?ans.puts()scanf()gets()printf() Previous Marked for Review Next

Which of the following function used as reading data ?Options :main()print()scanf()printf()

Explain different input and output functions in c with example (scanf,printf,gets,puts).

Which of these method of FileReader class is used to read characters from a file?Question 2Answera.read()b.scanf()c.get()d.getInteger()

Which of these method of FileReader class is used to read characters from a file?Optionsscanf()read()get()getInteger()

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.