W(caps)hat is variables ?
In the C programming language, A variable is a name of memory location which stores data.
Or
Variables are containers for storing data values.
Rules for variables :
- Variables are case sensitive
- First character must be an alphabet or ' _ ' (underscore)
- No comma or blank space are allowed
- Rather than underscore no other symbols are allowed.
Different Types of Variables :
In C programming language there are different types of variables :
- int : stores integers (whole numbers), without decimals, such as 123 or -123
- float : stores floating point numbers, with decimals, such as 19.99 or -19.99
- char : stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
Syntax to Declaring (Creating) Variables :
type variableName = value; (code-box)
Variable DataTypes :
DataTypes | Size in bytes |
---|---|
Char or signed char | 1 |
unsigned char | 1 |
int of signed int | 2 |
unsigned int | 2 |
short int of unsigned short int | 2 |
signed short int | 2 |
Alfreds Futterkiste | 4 |
long int or signed long int | 4 |
unsigned long int | 4 |
float | 4 |
double | 8 |
long double | 10 |
You have successfully completed this tutorial (alert-success)