C++ MCQ -4

Question 1:
 
cin extraction stops execution as soon as it finds any blank space character
 
a.       true
b.      false
 
Question 2:
 
Observe the following statements and decide what do they do.
 
string mystring;
 
getline(cin, mystring);
 
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
 
Question 3:
 
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
 
Question 4:
 
Which of the header file must be included to use stringstream?
 
a.       <iostream>
b.      <string>
c.       <sstring>
d.      <sstream>
 
Question 5:
 
Which of the following header file does not exist?
 
a.       <iostream>
b.      <string>
c.       <sstring>
d.      <sstream>
 
Question 6:
 
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
 
 
Question 7:
 
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
 
Question 8:
 
Which of the following is not a reserve keyword in C++?
 
a.       mutable
b.      default
c.       readable
d.      volatile
 
Question 9:
 
The size of following variable is not 4 bytes in 32 bit systems
 
a.       int
b.      long int
c.       short int
d.      float
 
Question 10:
 
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

Similar Posts

  • C++ MCQ -7

    Question 1 A variable is/are a.    String that varies during program execution b.    A portion of memory to store a determined value c.    Those numbers that are frequently required in programs d.    None of these   Question 2 Which of the following can not be used as identifiers? a.    Letters b.    Digits c.    Underscores d.   …

  • C++ MCQ -3

    Question 1: Find out the error in following block of code. If (x = 100)     Cout << ΓÇ£x is 100ΓÇ¥; a.       100 should be enclosed in quotations b.      There is no semicolon at the end of first line c.       Equals to operator mistake d.      Variable x should not be inside quotation   Question 2:…

  • C++ MCQ -6

    Question 1 In an assignment statement a=b; Which of the following statement is true? a.    The variable a and the variable b are equal. b.    The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable a c.    The value of b is…

  • C++ MCQ -1

    Question 1. What is the correct value to return to the operating system upon the successful completion of a program? A. -1 B. 1 C. 0 D. Programs do not return a value.   Question 2. What is the only function all C++ programs must contain? A. start() B. system() C. main() D. program()  …

  • C++ MCQ-14

    Q.61  An array element is accessed using (A)  a FIFO approach  (B)  an index number (C)  the operator  (D)  a member name     Ans:B   Q.62   If there is a pointer p to object of a base class and it contains the address of an object of a derived class and both classes contain…

  • C++ MCQ-16

    Q.91   What will be the result of the expression 13 & 25? (A) 38  (B)  25 (C)  9  (D)  12      Ans:C  Q.92   Which of the following operator can be overloaded through friend function? (A)  ->   (B)  = (C)  ( )   (D)  *        Ans:D   Q.93  To access the public function…

Leave a Reply

Your email address will not be published. Required fields are marked *