C Workshop · Arithmetic Operators
Lesson C

Arithmetic Operators

+ - * / % work on numbers. Integer / drops the fraction.

What it is

Arithmetic operators combine numbers: add, subtract, multiply, divide, remainder. This lesson multiplies 6 and 7 so you can watch a single expression become 42 and then get printed.

Approach

  1. Put the two numbers in an expression.
  2. Choose * here because the practice asks for a product.
  3. Print with %d and a newline.

Where this is used in the real world

Diagram

1

6

left

2

*

multiply

3

7

right

4

42

product

Run algorithm

Each step highlights the matching C line. Program output appears only when a line that prints actually runs.

Ready
C code
1#include <stdio.h>
2int main(void) {
3    printf("%d\n", 6 * 7);
4    return 0;
5}
What this line does
Press Run algorithm. The highlight will move through the C code.
6left
*
7right
= 42
Program output
(no output yet)

Check your understanding

Five questions. Pick one answer each, then Check answers. The correct choice turns green.

1. This lesson prints:

6*7=42.

2. Which operator is remainder?

Modulo.

3. 7 / 2 as ints is 3 because:

Truncation.

4. To get a fraction you often need:

At least one floating operand.

5. 6 + 7 * 2 is:

* before + : 6+14=20.