Calculate the area and perimeter of rectangle and area and circumference of circle coderinme

Program to calculate the area and perimeter of rectangle and area
and circumference of circle.

calculate the area and perimeter of rectangle and area
and circumference of circle.

we know the rectangle area=l*b
perimeter= 2(l+b)
circle 2*pi*r and pi*r*r

let’s begin
#!/bin/bash
(bash copy)
read -p "Enter radius of circle: " radius
read -p "Enter length of rectangle: " length
read -p "Enter breadth of rectangle: " breadth
pi=`seq -f '4/%g' 1 2 99999 | paste -sd-+ | sed "s/^/;scale=5;/g"| bc -l`
cir_area=`bc <<< "scale=2;$pi*$radius*$radius"`
cir_peri=`bc <<< "scale=2;2*$pi*$radius"`
rect_area=`bc <<< "scale=2;$length*$breadth"`
rect_peri=`bc <<< "scale=2;2*($length+$breadth)"`
echo "Area of the circle: " $cir_area
echo "Perimeter of the circle: " $cir_peri
echo "Area of rectangle: " $rect_area
echo "Perimeter of rectangle: " $rect_peri

Leave a reply:

Your email address will not be published.