Which of these statements are true and which are false? 1. T F Void returning fu
ID: 3887892 • Letter: W
Question
Which of these statements are true and which are false?
1. T F Void returning functions return exactly one function value.
2. T F . The statement cin.get(charVar); reads the first character, regardless of what it is, from the input stream cin (charVar has been declared as a char).
3 .T F The statement cin.skip(10);always skips 10 characters on the standard input stream.
4. T F The getline function terminates on trailing whitespace characters when reading from the input stream? T F h) The statement cin >> ch; reads the first character, regardless of what it is, from cin?
5. T F The size() function returns the number of characters contained in a string variable
6. T F The find() function returns string::npos if it successfully finds its argument.
Explanation / Answer
1.False. void is an empty return type. Means any function whose return type is void can't retur any value.
2. True. We use cin.get() function instead of the usual cin>> function when we want to have a control over the size of the input. In this case, size of charVar is 1 byte since it was declared as a character, the function will input only one character.
3. False. There is no statement as cin.skip() in the ctandard i/o library. We can use cin.ignore() statement to perform the similar task.
4. False. The getline() function does not terminate on the trailing white space characters when reading from the i/p stream. It only terminates when it finds the newline( ) character.
h. False. cin>> reads a value until it encounters a space.
5. True. It returns the number of bytes or characters held by the string for which the function is used.
6. False. It returns the position of the first occurrence of the passed argument if found else it returns string::npos when not found.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.