Tuesday, January 12, 2016

Shell program to calculate the area and circumference of the circle given the radius.


# circleare.sh
# Program :          To calculate the area and circumference of the circle given the
                             radius.
# Author :          sujith
# Date :              16/03/2015

clear
echo "Enter the radious of the circle"
read r
area=$(echo "3.14*$r*$r" | bc  )
circum=$(echo "3.14*2*$r" | bc)
echo "area of the circle is             " $area
echo "circumference of the circle is    " $circum

OUTPUT:

[141740@localhost ~]$ sh circlearea.sh
Enter the radius of the circle
3.5
area of the circle is            38.46
circumference of the circle is   21.98


5 comments: