Sail E0 Webinar

MCQs

Total Questions : 13 | Page 1 of 2 pages
Question 1.

What is the output of this program?

#include < iostream >

using namespace std;

int main () 

{

char str[] = "Steve jobs";

int val = 65;

char ch = 'A';

cout.width (5);

cout

  1.    Steve jobs
  2.    A
  3.    5
  4.    65
 Discuss Question
Answer: Option D. -> 65


In this program, We are printing the five spaces and then we are printing the value of 65.


Question 2.

What is the output of this program?

#include < iostream >

using namespace std;

int main () 

int n; 

n = 43;

cout

  1.    2c
  2.    2b
  3.    20
  4.    50
 Discuss Question
Answer: Option B. -> 2b


In this program, We are printing the hexadecimal value of the given decimal number by using hex function.


Question 3. What must be specified when we construct an object of class ostream?
  1.    stream
  2.    streambuf
  3.    memory
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> streambuf


If you construct an object of class ostream, you must specify a streambuf object to the constructor.


Question 4. How many types of output stream classes are there in c++?
  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option C. -> 3


There are three output stream classes in c++. They are ostream, ofstream and ostrstream.


Question 5. Which operator is used for input stream?
  1.    By seeing a blankspace
  2.    By seeing ()
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> By seeing a blankspace


cin will stop its extraction when it encounters a blank space.


Question 6.

What is the output of this program?

#include < iostream >

using namespace std;

int main ()

{

int i;

cout > i + 4;

return 0;

}

  1.    73
  2.    your value + 4
  3.    Error
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> Error


We are not allowed to do addition operation on cin.


Question 7. How many parameters are there in getline function?
  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option C. -> 3


There are three parameters in getline function. They are a pointer to an array of characters and maximum number of characters and a delim.


Question 8.

What is the output of this program?

#include < iostream >

using namespace std;

int main( )

{

char line[100];

cin.getline( line, 100, 't' );

cout

  1.    100
  2.    t
  3.    It will print what we give.
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> It will print what we give.


In this program, We are printing the input what we read from cin.


Question 9. When will the cin can start proceessing of input?
  1.    After pressing return key
  2.    BY pressing blankspace
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> After pressing return key


After pressing return key


Question 10. What can be used to input a string with blankspace?
  1.    inline
  2.    getline
  3.    putline
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> getline


If a user wants to input a sentence with blankspaces, then he may use the function getline.


Latest Videos

Latest Test Papers