ARMSTRONG NUMBER

echo "Enter the number"

read n

num=$n

sum=0

while [ $n -gt 0 ]

do

r=`expr $n % 10`

n=`expr $n \/ 10`

sum=`expr $sum + $r \* $r \* $r`

done

if [ $num -eq $sum ]

then

echo "The number $num is armstrong number"

else

echo "The number $num is not armstrong number"

fi

PRIME NUMBER

echo "Enter the number"

read n

i=2

while [ $i -lt $n ]

do

y=`expr $n \% $i`

if [ $y -eq 0 ]

then

echo "$n is not a prime number"

exit

fi

i=`expr $i + 1`

done

echo "$n is prime number"

SUM OF EVEN NUMBERS

echo “Enter upper limit”

read n

i=2

sum=0

until test $i –gt $n

do

sum=`expr $sum + $i`

i=`expr $i + 2`

done

echo “Sum is:$sum”

GERNERATING FIBONACCI SERIES

echo “Program to generate Fibonacci series”

echo “Enter the range to be displayed”

read n

a=0

b=1

echo “Fibo series”

echo $a

echo $b

i=2

while test $i –lt $n

do

c=`expr $a + $b`

echo $c

i=`expr $i + 1`

a=$b

b=$c

done

GENERATING MULTIPLICATION TABLE

echo “Enter the number”

read n

for I in 1 2 3 4 5 6 7 8 9 10

do

m=`expr $n \* $i`

echo “$i * $n”=$m

done

ARITHMETIC OPERATIONS USING CASE STATEMENT

echo “Enter the number”

read num

case $num in

1)echo “Enter the a value”

read a

echo “Enter the b value”

read b

C=`expr $a + $b`

Echo $c;;

2)echo “Enter the c value”

read c

echo “Enter the g value”

read g

D=`expr $c - $g`

echo $D;;

3)echo “Enter the d value”

read d

F=`expr $d \* 2`

echo $F;;

esac

ADDITION OF TWO NUMBERS USING POINTERS

#include<stdio.h>

main()

{

int a,b,c;

int *pa,*pb,*pc;

pa=&a;

pb=&b;

pc=&c;

printf(“\n Enter the first number”);

scanf(“%d”,pa);

printf(Enter the second number”);

scanf(“%d”,pb);

*pc=*pa+*pb;

printf(“\n The sum is %d”,*pc);

}

REVERSE OF A NUMBER

echo “enter the number”

read n

sum=0

while [ $n -gt 0 ]

do

r=`expr $n % 10`

sum=`expr $sum \* 10 + $r`

n=`expr $n / 10`

done

echo “the result is $sum”

SIMPLE CALCULATOR

echo "Enter the first number"

read a

echo "Enter the second number"

read b

echo "1.add"

echo "2.sub"

echo "3.mul"

echo "4.div"

echo "5.exit"

echo "Enter the option"

read op

case $op in

(1)c=`expr $a + $b`

echo "The result is $c";;

(2)c=`expr $a - $b`

echo "The result is $c";;

(3)c=`expr $a \* $b`

echo "The result is $c";;

(4)c=`expr $a \/ $b`

echo "The result is $c";;

(5)exit

esac

FACTORIAL NUMBER

echo "Enter the number"

read n

i=1

fact=1

while [ $i -le $n ]

do

fact=`expr $fact \* $i`

i=`expr $i \+ 1`

done

echo "The factorial of $n is: $fact"