C++: Iostream

This entry is part 6 of 61 in the series C++

C++ includes an extensive standard library that provides IO, input and output (and many other facilities).

A stream is a sequence of characters read from or written to an IO device.  For example, inputting form the keyboard and outputting to the console.

The term stream is intended to suggest that the characters are generated, or consumed, sequentially over time.

Using the IO library, we can prompt the user to give us two numbers and then print their sum.

#include <iostream>
using namespace std;

void main()

	int v1;
	int v2;

	cout << "Enter two numbers: ";

	cin >> v1 >> v2;
	cout << "The sum of " << v1 << " and " << v2
		<< " is " << v1 + v2;

	cout << endl;


You can use CTRL-F5 to run the above program.



Series Navigation<< C++: Addition of 2 numbers
C++: Printing the ASCII value of a char >>