echo "$num is an Armstrong number." else echo "$num is not an Armstrong number." fi 3) Write a shell script to Find sum of first n odd numbers. #!/bin/bash
# Read the value of n from the user
read -p "Enter the value of n: " n
# Initialize variables sum=0 odd=1
# Calculate the sum of first n odd numbers
for (( i=1; i<=n; i++ )) do sum=$((sum + odd)) odd=$((odd + 2)) done
# Output the result
echo "Sum of first $n odd numbers is: $sum" 4) Write a shell script to find multiplication of digits 123. #!/bin/bash
# Read the number from the user
read -p "Enter a number: " number
# Initialize product to 1 product=1
# Convert the number to an array of digits and multiply each digit
while [ $number -gt 0 ] do digit=$((number % 10)) product=$((product * digit)) number=$((number / 10)) done