C++ Data Types

Data Types help determine how the value will be stored in memory and what can be done to the value.

TypeDescriptionValuesCan't
inta whole number (Integer)0, 5, 3000, -456have a fractional part such as 0.0,3.14,5.6789
float6 to 7 digits1.23456
double15 to 16 digits if required for more precision. Will use more memory.1.234567890
boolused to make decisions in codetrue or false

Example: Integers can be added such as 3+5, but Integers can’t have fractionals such as 3+5.5

To put this into practice, let’s declare a variable

int main()
{
  int numberOfDeathStars; // decalared a variable
  numberOfDeathStars = 1; // variable has been initalized
  // = is an assignment operator
  // so now numberofDeathStars has been initalized with the value of 1
}