Bash shell script to calculate the area and circumference of a circle
kw.sh
#!/bin/bash

echo "———————————————————————————————————————————"
echo "Script to calculate the area and circumference of a circle"
echo "———————————————————————————————————————————"
echo -n "Enter the radius of circle "
read RADIUS
PI=3.14159
AREA=$(echo "$PI*($RADIUS^2)"|bc)
CIRCUM=$(echo "(2*$PI*$RADIUS)"|bc)
echo "Area of a circle is $AREA"
echo "Circumference of a circle is $CIRCUM"
echo "———————————————————————————————————————————"
Output
kodingwindow@kw:~$ bash kw.sh
———————————————————————————————————————————
Script to calculate the area and circumference of a circle
———————————————————————————————————————————
Enter the radius of circle 10
Area of a circle is 314.15900
Circumference of a circle is 62.83180
———————————————————————————————————————————
kodingwindow@kw:~$ 
Advertisement