C++ – Basic Input Output

C++ uses a convenient abstraction called streams to perform input and output operations in sequential media such as the screen, the keyboard or a file.
The standard library defines:

cin standard input stream
cout standard output stream

Sample


// i/o example

#include <iostream>
using namespace std;

int main ()
{
  int i;
  // character output
  cout << "Please enter an integer value: ";
  // character input is stored in variable
  cin >> i;
  cout << "The value you entered is " << i;
  cout << " and its double is " << i*2 << ".\n";
  return 0;
}

The result is:
Please enter an integer value: 702
The value you entered is 702 and its double is 1404.