2024-09-24 22:39:42 +00:00
|
|
|
#!/usr/bin/env bellos
|
2024-10-03 04:14:47 +00:00
|
|
|
# File: basic_math.bellos
|
2024-09-24 22:39:42 +00:00
|
|
|
|
2024-10-03 04:14:47 +00:00
|
|
|
# Demonstrating arithmetic operations
|
2024-09-24 22:39:42 +00:00
|
|
|
|
2024-10-03 21:01:27 +00:00
|
|
|
# Addition
|
|
|
|
result=$((5 + 3))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Addition: "5 + 3 =" $result
|
2024-09-24 22:39:42 +00:00
|
|
|
|
2024-10-03 21:01:27 +00:00
|
|
|
# Subtraction
|
|
|
|
result=$((10 - 4))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Subtraction: "10 - 4 =" $result
|
2024-09-24 22:39:42 +00:00
|
|
|
|
2024-10-03 21:01:27 +00:00
|
|
|
# Multiplication
|
|
|
|
result=$((6 * 7))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Multiplication: "6 * 7 =" $result
|
2024-09-24 22:39:42 +00:00
|
|
|
|
2024-10-03 21:01:27 +00:00
|
|
|
# Division
|
|
|
|
result=$((20 / 4))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Division: "20 / 4 =" $result
|
2024-10-03 04:14:47 +00:00
|
|
|
|
2024-10-03 21:01:27 +00:00
|
|
|
# Modulus
|
|
|
|
result=$((17 % 5))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Modulus: "17 % 5 =" $result
|
2024-10-03 04:14:47 +00:00
|
|
|
|
2024-10-03 21:01:27 +00:00
|
|
|
# Compound operation
|
|
|
|
result=$(( (10 + 5) * 2 ))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Compound: "(10 + 5) * 2 =" $result
|
2024-10-03 04:14:47 +00:00
|
|
|
|
2024-10-03 21:01:27 +00:00
|
|
|
# Using variables
|
2024-10-03 04:14:47 +00:00
|
|
|
a=7
|
|
|
|
b=3
|
2024-10-03 21:01:27 +00:00
|
|
|
result=$((a + b))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Variables: "$a + $b =" $result
|
2024-10-03 21:01:27 +00:00
|
|
|
|
|
|
|
# Increment
|
|
|
|
count=0
|
|
|
|
count=$((count + 1))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Increment: count after increment "=" $count
|
2024-10-03 21:01:27 +00:00
|
|
|
|
|
|
|
# Decrement
|
|
|
|
count=$((count - 1))
|
2024-10-05 15:54:36 +00:00
|
|
|
echo Decrement: count after decrement "=" $count
|
2024-10-03 04:14:47 +00:00
|
|
|
|
|
|
|
echo Basic math operations completed.
|