Skip to content

Commit be0aa9b

Browse files
author
Julia
committed
Simple looping and arithmetic
0 parents  commit be0aa9b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

numbers.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
echo "Printing all numbers in range 1 to 10"
4+
for x in {1..10}; do echo $x; done
5+
# That is how to output empty line
6+
echo -en "\n"
7+
8+
echo "Printing all odd number in range 1 to 10"
9+
seq 1 2 10
10+
echo -en "\n"
11+
12+
echo "Let's do some arithmetic. Give me first number: "; read a
13+
echo "Give me second number: "; read b
14+
echo "The sum is $(($a+$b))"
15+
echo "The difference is $(($a-$b))"
16+
echo "The product is $(($a*$b))"
17+
if (($b == 0)); then
18+
echo "Division by 0 is not allowed";
19+
else
20+
echo "The quotient is $(($a/$b))"
21+
fi
22+
echo -en "\n"
23+
24+
25+
echo "Let's compare two numbers. Give me first number: "; read a
26+
echo "Give me second number: "; read b
27+
if (($a > $b)); then
28+
echo "The first one is bigger";
29+
elif (($a < $b)); then
30+
echo "The second one is bigger";
31+
else
32+
echo "The are equal!";
33+
fi

0 commit comments

Comments
 (0)