Basic Data Types:

C++ provides a rather large number of types. However, you can write perfectly good programs using only five of those:

Data Type Description Example
int for an integer number 0, -8, 420
double for a floating-point number 0.0, 3.14, 420.0
char for a individual number '!', '@', 'a'
string for a string of characters "Hello, World!" "Howdy!"
bool for a logical variable true, false


  • int: for an integer number
  • double: for a floating-point number
  • char: for an individual character
  • string: for a string of caracters
  • bool: for logical variables (true/false)

Datatype Modifiers:

As the name implies, datatype modifiers are used with the built-in data types to modify the length of data that a particular data type can hold. Data type modifiers in C++ are:

  • signed
  • unsigned
  • short
  • long

Const:

const (constant) variables cannot be changed by your program during execution.

Conversions:

The notation type(value) means "convert value to type". So for example:

double weight = 4.0;

int(weight);

// weight is now an int variable
Made in NYC © 2018 Codecademy