C++ Basic Input/Output

The C++ programming language has a variety of libraries that assist us in executing input-output operations. In C++, input and output stream sequences of bytes are referred to as streams. There are two distinct stream types.

It’s them,

Input source

The direction of the bytes flowing in the input stream is from the input device (such as the keyboard) to the main memory.

Output stream

The output stream’s bytes go from the main memory to the output device in that order (for ex-display)

An illustration of how input and output are commonly carried out in C++

#include <iostream>
using namespace std;
 
int main()
{
    int num;
    cout << "Enter a number: ";
    cin >> num;                        // Getting input from the user
    cout << "Your number is: " << num; // Displaying the input value
    return 0;
}

Input:

Enter a number: 10

Output:

Your number is: 10

Significant Points

  • The insertion operator is also known as the sign.
  • The extraction operator is the symbol >>.
  • cout is a printing keyword.
  • Run-time input is taken via the cin keyword.
Shubhajna Rai
Shubhajna Rai

A Civil Engineering Graduate interested to share valuable information with the aspirants.

Leave a Reply

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

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in