# Variables

Displaying text is pretty good, but something that computers are great at is calculating (and repetition, which we will discuss in the loops section later). To do this, we need to store the numbers in something called a variable. Declare a variable with int and assign it a number. Then we can perform calculations on it!

``` #include <stdio.h> int main() {     int x = 0;     int y = 3;     // Perform x + 20 (0 + 20) and assign it to x:     x = x + 20;     // Shorthand way of saying perform x - 16 and assign to x:     x -= 16;     // Perform other calculations on x     x /= 2; // Divide by 2     x *= 3; // Multiply by 3     x %= 2; // Get the remainder after dividing by 2     x += y; // Add y to x     // Print the value of x     printf("%i\n", x);     return 0; } ```

What is the modulo operator (%)? It means get the remainder after dividing by the value (in this case 2). It means that the value of x will be either 1 (divided by 2 remainder 1) or 0 (no remainder).
Note the use of shorthand expressions for arithmetic. A lot of mathematicians will not like "x = x + 1;" for example, so I tend to use the more mathematician friendly "x += 1;"
%i in the printf function is used to print integers, you can print more than one, for example:

``` printf("%i, %i\n", x, y); ```

Also, note the use of "*" instead of "x" to multiply a value, as x can be confused with variable names for instance.

What about numbers with a decimal point in it? Well you can use the float, double, or long double variable types instead of int. You can try changing the above source code to calculate floating point numbers. Note you will need to change the %i to something else, like %f or %Lf for example.