Shell Script To Find The Area Of A Triangle

SCRIPT:

#!/bin/bash

#This script used to find the area
#of the triangle. user need to give
#the base and height of the triangle

echo -n "Please enter the base and height of the triangle : "
read base
read height
area=`expr "scale=2; 1/2*$base*$height"|bc`
echo "area of the triangle = $area"

RUN:

sh triangle.sh

OUTPUT:

Please enter the base and height of the triangle : 10
25
area of the triangle = 125.00


No comments:

Post a Comment