On this mastery I will show you some basic variable types in C++, how and when to use them. 

There are several types in C++ but the basic ones are char, int, long, float, and double.

Each one serves a specific purpose when a variable is used.

char type consists of characters used in a function. It is used when your output will consist of a character or characters. For example, we used it on mastery 19 when our output was a character.

int type is the most used and common in C++. We can use it for numbers but not so big ones. We used it on mastery 10 where our output was a simple math operation.

long type is similar to int but allows us to have bigger integer number outputs. We used it on mastery 21 where our factorial numbers could get bigger.

float and double allows us to have non integer number outputs. For example, the division of 3/2 = 1.5, float allows us to have that output and double works as long, where we can have bigger non-integer number outputs. float was used on wsq10 where a divition could be a non-integer number.

Hope I could clear some doubts and hopefully you know now when to use each type!

CC BY 4.0 Mastery 9 by Omar Peza is licensed under a Creative Commons Attribution 4.0 International License.