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 -2

    Question 1: The void specifier is used if a function does not have return type. a.       True b.      False   Question 2: You must specify void in parameters if a function does not have any arguments. a.       True b.      False   Question 3: Type specifier is optional when declaring a function a.       True b.      False…

  • C++ MCQ-10

    Q.16   If we create a file by ΓÇÿifstreamΓÇÖ, then the default mode of the file is _________    (A)  ios :: out  (B)  ios :: in (C)  ios :: app  (D)  ios :: binary     Ans: B   Q.17   A variable defined within a block is visible        (A) from the point of…

  • 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 -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 -8

    Question 1 Identify the correct statement a. Programmer can use comments to include short explanations within the source code itself. b. All lines beginning with two slash signs are considered comments. c. Comments very important effect on the behaviour of the program d. both   Question 2 The directives for the preprocessors begin with a.   …

  • 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.   …

Leave a Reply

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