Powered by Blogger.

Write a shell script to check whether a given number is an Armstrong number or not.

echo "Enter a number: " read c x=$c sum=0 r=0 n=0 while [ $x -gt 0 ] do r=`expr $x % 10` n=`expr $r \* $r \* $...
Read More

Write a shell script to check whether a given number is prime or not.

echo "Enter a number: " read num i=2 f=0 while [ $i -le `expr $num / 2` ] do if [ `expr $num % $i` -eq 0 ] then f=1...
Read More

Write a shell script to find the sum of the first n numbers.

echo "Enter a number: " read num i=1 sum=0 while [ $i -le $num ] do sum=`expr $sum + $i` i=`expr $i + 1` done echo...
Read More

Write a shell script to find whether a given year(4 digits)is leap year or not.

echo "Enter the year in 4 digits: " read num if [ $num -ge 1000 -a $num -le 9999 ] then  if [ `expr $num % 4` -eq 0 ] ...
Read More