0% found this document useful (0 votes)
2 views

Basic Input

In C++, input and output are managed through streams, with input streams receiving data from devices like keyboards and output streams sending data to devices like display screens. The <iostream> header file contains standard input and output tools, with 'cout' for output and 'cin' for input being the most commonly used. The 'cout' instance of the ostream class utilizes the insertion operator (<<) to display data on the standard output device.

Uploaded by

kiranbedi820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Basic Input

In C++, input and output are managed through streams, with input streams receiving data from devices like keyboards and output streams sending data to devices like display screens. The <iostream> header file contains standard input and output tools, with 'cout' for output and 'cin' for input being the most commonly used. The 'cout' instance of the ostream class utilizes the insertion operator (<<) to display data on the standard output device.

Uploaded by

kiranbedi820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Basic Input / Output

in C++
In C++, input and output are performed in the form of a sequence of bytes or more
commonly known as streams.
Input Stream: If the direction of flow of bytes is from the device (for example,
Keyboard) to the main memory then this process is called input.
Output Stream: If the direction of flow of bytes is opposite, i.e. from main memory
to device (display screen) then this process is called output.
All of these streams are defined inside the <iostream> header file which contains all
the standard input and output tools of C++. The two instances cout and cin of
iostream class are used very often for printing outputs and taking inputs respectively.
These two are the most basic methods of taking input and printing output in C++.
Standard Output Stream – cout
The C++ cout is the instance of the ostream class used to produce output on the standard output device which is

2
1
usually the display screen. The data needed to be displayed on the screen is inserted in the standard output stream
(cout) using the insertion operator(<<).
/ cout
int
Printing
return
main()
a <<
= 0;
22;
variable
a;{ 'a' using cout
}Syntax
cout << value/variable;

de
amespace
<iostream>
std;

Ex:
#include <iostream>
using namespace std;

int main() {

// Printing the given text using cout


cout << "GeeksforGeeks";
return 0;
}

Output :
Explanation: In the above program, cout is used to output the text “GeeksforGeeks” to the standard output stream. It works in conjunction w
the insertion operator (<<) to send the specified data to the output stream.
We can also print the variable values using cout.

You might also like