← Linux and the Command Line Lesson 42 of 51 · 5 XP

Warm-up: add two numbers warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

To the shell everything is a string. To calculate, write $(( ... )):

read a b
echo $((a + b))

read a b puts the first word of the line into a and the second into b.

Task. Read two integers from one line and print their sum.

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.