We store information in RAM through variables and there are certain data types that are used for this.
You do not need to know off the top of your head how many bytes each data type holds, this is just for informational purposes. Focus on knowing when to use each data type and what each of them stores.
int: stores integers (2 or 4 byte)
int a = 1;
float: stores decimal numbers to about 6 digits of precision (4 byte)
float b = 1.555555;
double: stores decimal numbers to about 15 digits of precision (8 byte)
double c = 0.999999999999999;
long (int): stores big integers, the ‘int’ is optional (8 byte)
long d = 123456790;
long double: stores big decimal numbers to about 19 digits of precision (10 byte)
long double e = 1.0000000000000000001;
char: stores a single character (1 byte)
char f = '@';
string: an array of char’s that allows you to form words
char[] g = "hello";
void: stores no value (useful for functions)
void h(int i) {
// some code in your function
// there will be no return here
}
If you wish to get user input and hold it to a variable or display the variable to the string, you will need to use a format specifier. Each data type has its own format specifier except for void.
float j = 4.5678;
("%0.2f", j); // it would display 4.57 printf
To check the value range or another specifier: