linux - Get a radius of a circle in bash shell -
i need write script find radius of circle , find area while circumference given
#!/bin/bash echo -n "enter circumference: " read circ pi=3.14 let rad=$(($circ/((2*$pi )) )) let area=$pi * $rad * $rad echo "the area of circle is: "$area""
the formula is: radius=circumference/(2 * pi) problem cant make formula work because bash doesn't accept decimal division read lot of answers there still can't want
i have like
let rad=$(($circ/((2*$pi )) ))
was trying lot of different variants,used bc -l still can't right , there mistakes
echo -n "enter circumference: " read circ pi=3.14 rad=`bc -l <<< "$circ/(2*$pi)"` echo $rad area=`bc -l <<< "$pi*$rad*$rad"` echo "the area of circle is: "$area""
Comments
Post a Comment