Learning C-Style C++


by Direct Approach Mentoring



int char bool float

2. Types

Type keywords allow you to create a variable, which is a container to store something like a number, or a character, etc.
Numbers and characters are examples of two different types of data. Here's how to create a number called

n

and a character called

letter

:

int

n;

char

letter;



Remember that when you create a variable, it will contain random garbage at first.
For example,

n

could start out containing the number

-84592

.


Here's how to create a 'boolean' (

true

or

false

value) and a 'floating-point' (decimal value like

0.475

):

bool

b;

float

f;