C++ Interview Questions on I/O Stream

During the development of the C++ programming language, a new class based on input and output operations was implemented, which gave birth to the I/O streams in C++. In this article, I’ll introduce you to some important C++ interview questions about I/O Stream.

C++ Interview Questions on I/O Stream

Let’s have a look at some of the most important C++ interview questions on I/O stream. The questions below are not the only questions based on I/O stream but these are enough to give you an idea what type of questions you may get.

Also, Read – Data Structures and Algorithms using C++.

Write a C++ program to enter a character and get its octal, decimal, and hexadecimal code as an output:

Please enter a character :aman
 The Character ahas code 97
     Octal  Decimal  Hexadecimal      141      97      61

Formulate the below I/O stream operations using the C++ programming language:

  1. Left-justify the number 0.123456 in an output field that is 15 wide.
  2. Output the number 23987 as a fixed-point number rounded to two decimal places, right-justifying the output in a field that is 12 wide.
  3. Output the number –123.456 in exponential form and with four decimal spaces. What is the use of a field width of 10?
0.123456
        23.99
 1.2346e+002

Write a C++ program that reads an item number, quantity, and unit price from the keyboard and displays the data on the screen:

Please enter features of the itemItem No. :Cool
 Number of Pieces:    Price Per Piece
         Item Number   Quantity   Price per piece
                0               0            0.00Dollar

So these were some of the important types of interview questions that you may face during a coding interview based on input and output operations. All the above questions need logical thinking so try to solve more programs that require you to think logically.

Also, Read – 100+ Machine Learning Projects Solved and Explained.

I hope you liked this article on C++ interview questions based on I/O Stream. Feel free to ask your valuable questions in the comments section below.

Default image
Aman Kharwal

Coder with the ♥️ of a Writer || Data Scientist | Solopreneur | Founder

Articles: 998

Leave a Reply