C++ Input/Output

Last Updated :
Discuss
Comments

Question 1

Which header file is required to use cin and cout in C++?

  • <stdio.h>

  • <iostream>

  • <stdlib.h>

  • <conio.h>

Question 2

What does endl do in C++ output?

  • Terminates the program

  • Clears the screen

  • Inserts a newline and clears the buffer

  • Converts input to lowercase

Question 3

Which object is used for standard input in C++?

  • output

  • Intput

  • cin

  • cinput

Question 4

Which of the following is true about cin in C++?

  • It requires format specifiers

  • It is faster than scanf()

  • It uses the >> operator

  • It cannot read strings

Question 5

What happens when you use cin >> str and input contains spaces?

  • Reads entire line

  • Reads until newline

  • Reads until first space

  • Reads after newline only

Question 6

What is the purpose of cin.getline()?

  • Reads an integer

  • Reads a single character

  • Reads a line with spaces

  • Skips input

Question 7

Which object is used for error output in C++?

  • cerr

  • clog

  • cout

  • cin

Question 8

What is the difference between cerr and clog?

  • cerr is buffered, clog is not

  • Both are same

  • cerr is unbuffered, clog is buffered

  • clog is input

Question 9

Which of the following reads a single character in C++?

  • cin.read()

  • cin.get()

  • cin.line()

  • getline(cin, var)

Question 10

What will getline(cin, str) do?

  • Read until space

  • Read until newline

  • Read character only

  • None

Tags:

There are 19 questions to complete.

Take a part in the ongoing discussion