NEW
Font size
WorksheetsC++ Input/Output Quiz
Total questions: 22
Worksheet time: 11mins
Which header file is needed to use cin and cout?
stdio.h
iostream
conio.h
cstdlib
What does cout stand for?
Console Output
Character Out
Current Output
Compiler Output
Which operator is used with cout?
>>
>
> "Hello World";
cout > x;
What is inserted by endl in C++ output?
Space
Newline
Tab
Nothing
Which of the following outputs a newline?
cout > num;
cout >> num;
cout > a, b;
cin >> a >> b;
What is the output of: cout > str;
cin.getline(str, 100);
getline(cin, str);
All of the above
Which one reads a line including spaces into a string variable?
cin >> str;
getline(cin, str);
cin.get(str);
cin.str();
cout belongs to which class?
ios
ostream
istream
iostream
cin belongs to which class?
ios
ostream
istream
iostream
Which is correct to print tab between two numbers?
cout >
=
*
What will happen if wrong type is entered for cin?
Program stops
cin goes into fail state
Value auto-converts
Compiler error
Which function resets cin after failure?
cin.fail()
cin.clear()
cin.reset()
cin.flush()
What does cin.ignore() do?
Ignores one character
Ignores entire line
Ignores whitespace
Ignores errors
What is the output of: cout > c;
char c; cin.get(c);
Both A and B
None
What is default base for cout numbers?
Decimal
Binary
Octal
Hex
Which manipulator sets number base to hex?
sethex()
hex
base(16)
HEX
Which manipulator sets number base to octal?
oct
setoct()
base(8)
eight
Which manipulator restores base to decimal?
dec
setdec()
base(10)
reset
Which keyword is needed for using cin and cout?
class
std
using namespace std;
Both B and C
Which of the following prints "100%" correctly?
cout << "100%";
cout << 100%;
cout << "100%%";
cout << 100 << %;
Which is the correct input/output type in C++?
Stream-based
Function-based
Macro-based
File-based only
What is the correct file extension for standard C++ source?
.c
.cpp
.h
.exe
