Answer to Question #256130 in UNIX/Linux Programming for Kar

Question #256130
1. Write a script to find the are of rectangle. 2. Write a script to find the area of square.
1
Expert's answer
2021-10-28T01:24:38-0400
Area of Rectangle = Length x Breadth
#/bin/bash
#Shell Script to find the area of rectangle

echo "Enter the length of the rectangle:"
read length
echo "Enter the breadth of the rectangle:"
read breadth

area=`expr $length \* $breadth`
echo "Area of Rectangle = $area"



2.Write a script to find the area of square

#!/bin/bash
#script to find area of a square based on user input

if [ $# -ne 1 ]
then 
   echo " Usage -$0 x "
   echo " where x is the dimension of the square "
   exit 1
fi
n1=$1
echo " Area of the square is equal to `expr $n1 \* $n1` "

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS