C++ -3 data types, variables and constants

Data type:



Bool defines whether or not, and has only true and false values

Char Defines characters whose values are ‘a’, where ‘b’ is enclosed in single quotes

Int defines an integer

Float defines decimals

Double defines more decimal places

Void returns no value. Void returns no value.

Variables: Variables should be declared before they are used. Declare it as follows. int i, j, k; char c, ch; float f, salary; double d;

The idea behind a variable is to give a name to an unknown quantity.

Constants: quantities that never change

1 Use #define preprocessor. 2 Use the const keyword

#define X 10 const int Y= 10;

Now neither X nor Y can change.