shell scripting for area of square,rectangle,circle

In our childhood many of us used to hate mathematics where we need to calculate the areas of the different shapes.There we need to remember the formulas of each and every shape.Today we shall write the program to find area of square,rectangle,circle so that we can use them in future. We use the childhood formulas for calculation of area of above mentioned geometrical figures.

  1. For square side * side
  2. For rectangle lenght * breadth
  3. For circle 3.14 * radius * radius

The code is:

echo “Enter the side of the square:”
read s
echo “Enter the length and breadth of rectangle:”
read leng
read brea
echo “Enter the radius of the circle:”
read radius
echo “Area of the square is:` expr $s \* $s ` ”
echo “Area of the rectangle is: `expr $leng \* $brea`”
echo “Area of the circle is: `expr 3.14 \* radius \* radius`”

output:
Enter the side of the square:5
Enter the length and breadth of rectangle: 10 6
Enter the radius of the circle:8
Area of the square is:25
Area of the rectangle is:60
Area of the circle is:200.96

Advertisement

About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my PhD in Computer Science.
This entry was posted in Shell scripting and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s