Shell Scripting Codes - Loops

 Shell Scripting-Loops

Practice Questions 

1.Write Shell Script to print 1 to 10 numbers 

#!/bin/bash
for (( i=1; i<=10; i++ ))
do
  echo $i
done

2.Write shell script to print multiplication table of input number 

#!/bin/bash
echo "Enter the number for the multiplication table:"
read num
for (( i=1; i<=10; i++ ))
do
  product=$((num * i))
  echo "$num x $i = $product"
done 

3.Write shell script to display the 25 to 1 numbers in reverse order 

#!/bin/bash
for (( i=25; i>=1; i-- ))
do
  echo $i
done
 

Comments

Popular posts from this blog

shell script collection

OS Lab Record