Knowee
Questions
Features
Study Tools

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

Question

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

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

Solution

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

Here's why:

  1. gets(): This function is used to read a line from the standard input (keyboard) and store it in an array of type char. It can read multi-word strings as it does not stop reading input on encountering the first white space.

  2. puts(): This function is used to write a string to the standard output (screen). It is not used for reading strings.

  3. printf(): This function is used to output a string to the standard output. Like puts(), it is not used for reading strings.

  4. scanf(): This function is used to read input from the standard input. However, it stops reading input on encountering the first white space, so it is not suitable for reading multi-word strings.

Therefore, gets() is the most appropriate function for reading in a multi-word string.

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()

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()

you can read a single word at a time from a file usingSelect one:a.fgetc functionb.fscanf functionc.Both A and Bd.None of above

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.