Back to Freecodecamp

Learn Variables and Operators Lesson E

curriculum/challenges/english/blocks/top-learn-variables-and-operators/65e19bc3500d930ce8ed90a8.md

latest1.2 KB
Original Source

--description--

Numbers are the building blocks of programming logic! In fact, it’s hard to think of any useful programming task that doesn’t involve at least a little basic math… so knowing how numbers work is obviously quite important. Luckily, it’s also fairly straightforward.

OperatorDescriptionExample
+Addition5 + 3 = 8
-Subtraction5 - 3 = 2
*Multiplication5 * 3 = 15
**Exponentiation5 ** 3 = 125
/Division6 / 3 = 2
%Modulus5 % 3 = 2

--assignment--

Given the table of operators above, write a simple program snippet that demonstrates the use of each operator with the variable x initialized to 10.

--questions--

--text--

What is the result of applying the modulus operator to x where x = 10?

--answers--

x % 3 results in 1


x % 3 results in 3


x % 3 results in 0


x % 3 results in 2

--video-solution--

1