Saturday, 16 July 2016

Write a shell script in Linux/Unix to solve the expression--x2+7x+12=0


tput clear
echo THE expression is-X^2+7X+12=0
echo roots are---
a=1
b=7
c=12
p=`expr $b \* $b`
s=`expr $a \* $c`
v=`expr $s \* 4`
k=`expr $p - $v`
m=`echo $k ^ 0.5 |bc`
l=`echo -$b + $m |bc`
l1=`echo -$b - $m |bc`
o=`expr 2 \* $a`
x1=`echo $l / $o |bc`
x2=`echo $l1 / $o |bc`
echo X1= $x1
echo X2= $x2


OUTPUT:

THE expression is-X^2+7X+12=0
roots are---
X1= -3
X2= -4









No comments:

Post a Comment

Popular Posts