Data types define what information is stored
The most used of them are:
| int | Whole number. |
|---|---|
| double | Floating point number. |
| string | Sequence of characters (text). In order to be used the
line #include<string> must be added. |
| char | Represents a single symbol. |
| bool | Can have only 2 values - true or false. |
cin - reading data, followed by >> operator.cout - printing data, followed by << operator.In order to use them the line
#include<iostream> needs to be added.
The variables are used to store data of certain type.
Their value can be changed any time.
Example of variables definitions:
Write a program that prints "Starting the program." Afterwards it must read a word and print it back.
Solution:
Input:
Output:
Explanation:
#include<iostream> is added so cin and cout
can be used. << endl is used to print a new line.