Saturday, January 11, 2014

PROGRAM TO DETERMINE THE AREA OF A TRIANGLE

echo "Enter the base and height of the triangle"
read b
read h
c=`expr $b \*  $h \* $h`
area=`expr $c / 2`
echo " Area of the triangle is  $area"

OUTPUT

[staff@linuxserver staff]$ sh triangle.c
Enter the base and height of the triangle
10
8

 Area of the triangle is  320

PROGRAM TO FIND THE REVERSE OF A NUMBER

echo "enter the number"
read n
u=0
while test $n  -ne 0
do
u=`expr $n % 10`
n=`expr $n / 10`
echo $u
done



OUTPUT:
 [eceb33@linuxserver eceb33]$ sh reverse
enter the number
347
7
4
3

No comments:

Post a Comment