Standard Output (cout)
- The cout and insertion (<<) operator can print a message on the screen.
- To print the variables, there is no need to used double quotes ( “” ).
- The insertion operator (<<) can be used multiple times in a single statement.
- It is possible to combine variables and text.
Example:
cout<< "Welcome to TutorialRide!!!";
Example:
int a=10;
count << a;
Example:
cout<< "Welcome" << "to" << "TutorialRide";
Example:
int a = 10;
cout<< "Print number"<<a;
Standard Input (cin)
- The cin and extraction (>>) operator reads input from the keyboard.
- The cin operator returns the variable type.
Example
int num;
cout<< "Enter number:"
cin>>num;
cout<<num;
Manipulators
- Manipulators are used to manipulate the data by the programmer's choice of display.
- It is used to specify certain formats of the output to be displayed when using the cout statement.
- It performs certain special operations such as moving the cursor to new line, fixing the width of a data value etc.
| Manipulators | Description |
|---|---|
| endl | It feeds the whole line and then points the cursor to the beginning of the next line. '\n' is used instead of endl for the same purpose. |
| setw | It sets the minimum field width on output. |
| setfill | It is used after setw manipulator. It is used for filling the fields. |
| setprecision | It is used to set the precision for a data after the decimal point. |
Storage Classes
- Storage class is a type specifier that governs the lifetime, linkage and memory location of objects.
- It defines the scope and lifetime of variables or functions within a C++ program.
| Storage Class | Description |
|---|---|
| auto | It is the default storage class for all local variables. |
| register | This storage class is used to define local variables that should be stored in a register instead of RAM. |
| static | This class is used for specifying the static variable. |
| extern | This class is used to give a reference of a global variable which is available to all program files. |
| mutable | This class allows a member of an object to override constness that means this class can be modified by a const member function. |


