#!/usr/bin/env bellos # File: control_structures_with_seq.bellos # 1. Simple echo and variable assignment echo "Demonstrating if-else statements:" x=10 # 2. If-else statement if [ $x -gt 5 ] then echo "x is greater than 5" else echo "x is not greater than 5" fi # 3. Nested if-else echo "Demonstrating nested if-else:" y=20 if [ $x -gt 5 ] then if [ $y -gt 15 ] then echo "x is greater than 5 and y is greater than 15" else echo "x is greater than 5 but y is not greater than 15" fi else echo "x is not greater than 5" fi # 4. While loop echo "Demonstrating while loop:" counter=0 while [ $counter -lt 5 ] do echo "Counter: $counter" counter=$((counter + 1)) done # 5. For loop echo "Demonstrating for loop:" for i in 1 2 3 4 5 do echo "Iteration: $i" done # 6. For loop with seq command echo "Demonstrating for loop with seq command:" for i in $(seq 1 5) do echo "Number from seq: $i" done # 7. Using seq with different arguments echo "Demonstrating seq with different arguments:" echo "seq 3 (implicit start at 1, increment by 1):" for i in $(seq 3) do echo "Value: $i" done echo "seq 2 5 (start at 2, increment by 1):" for i in $(seq 2 5) do echo "Value: $i" done echo "seq 0 2 10 (start at 0, increment by 2):" for i in $(seq 0 2 10) do echo "Value: $i" done # 8. Case statement echo "Demonstrating case statement:" fruit="apple" case $fruit in "apple") echo "It's an apple" ;; "banana") echo "It's a banana" ;; "orange") echo "It's an orange" ;; *) echo "Unknown fruit" ;; esac # 9. Using seq in arithmetic operations echo "Using seq in arithmetic operations:" sum=0 for i in $(seq 1 5) do sum=$((sum + i)) echo "Running sum: $sum" done echo "Final sum of numbers 1 to 5: $sum" echo "Control structures and seq demonstration completed."