Following are the multiple choice questions from C++. Please scroll down to check the answers.
cin extraction stops execution as soon as it finds any blank space character
Observe the following statements and decide what do they do.
a. reads a line of string from cin into mystring
b. reads a line of string from mystring into cin
c. cin can’t be used this way
d. none of above
Regarding stringstream identify the invalid statement
a. stringstream is defined in the header file <sstream>
b. It allows string based objects treated as stream
c. It is especially useful to convert strings to numerical values and vice versa.
d. None of above
Which of the header file must be included to use stringstream?
Which of the following header file does not exist?
If you use same variable for two getline statements
a. Both the inputs are stored in that variable
b. The second input overwrites the first one
c. The second input attempt fails since the variable already got its value
d. You can not use same variable for two getline statements
The “return 0;” statement in main function indicates
a. The program did nothing; completed 0 tasks
b. The program worked as expected without any errors during its execution
c. not to end the program yet.
d. None of above
Which of the following is not a reserve keyword in C++?
The size of following variable is not 4 bytes in 32 bit systems
b. long int
c. short int
Identify the correct statement regarding scope of variables
a. Global variables are declared in a separate file and accessible from any program.
b. Local variables are declared inside a function and accessible within the function only.
c. Global variables are declared inside a function and accessible from anywhere in program.
d. Local variables are declared in the main body of the program and accessible only from functions.
1. a. True
2. a. Reads a line of string from cin into mystring
3. d. None of above
4. d. <sstream>
5. c. <sstring>
6. b. The second input overwrites the first one
7. b. The program worked as expected without any errors during its execution
8. c. readable
9. c. short int
10 b. Local variables are declared inside a function and accessible within the function on