Showing posts with label finding the area of a circle in bash. Show all posts
Showing posts with label finding the area of a circle in bash. Show all posts

Sunday, May 31, 2015

Finding the Area of a Circle Using BASH

In this article I would like to share with you a sample program that I wrote using Bourne Again Shell or BASH scripting language that is being used in UNIX and LINUX operating system. What does the program will do is to ask the user to enter the radius of the circle and then our program will compute the area of the circle.

The script is very simple and short is very easy to understand and read. If you have some questions regarding about my works feel free to send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippine who wish to contact me can reach me through my mobile number 09173084360.

Thank you very much and Happy Programming.




Sample Program Output


Program Listing


#!/bin/bash

echo -e "\n\n"
echo -e "\t\t FINDING THE AREA OF THE CIRCLE IN BASH"
echo -e "\n"
read -p  "Kindly give the radius of a circle :=> " radius
echo -e "\n"

area=$(echo "scale=2;3.14159 * ($radius * $radius)" | bc)

printf "The area of the circle is %0.2f." $area
echo -e "\n"
echo -e "Thank you for using this program."