Answer:
PROGRAM QuadraticEquation
Solver
IMPLICIT NONE
REAL :: a, b, c
;
REA :: d
;
REAL :: root1, root2
;
//read in the coefficients a, b and c
READ(*,*) a, b, c
WRITE(*,*) 'a = ', a
WRITE(*,*) 'b = ', b
WRITE(*,*) 'c = ', c
WRITE(*,*)
// computing the square root of discriminant d
d = b*b - 4.0*a*c
IF (d >= 0.0) THEN //checking if it is solvable?
d = SQRT(d)
root1 = (-b + d)/(2.0*a) // first root
root2 = (-b - d)/(2.0*a) // second root
WRITE(*,*) 'Roots are ', root1, ' and ', root2
ELSE //complex roots
WRITE(*,*) 'There is no real roots!'
WRITE(*,*) 'Discriminant = ', d
END IF
END PROGRAM QuadraticEquationSolver
Explanation:
in c++
#include<iostream.h>
#using namespace std;
main()
{ float x,y,z,r, phi, theta;
cout<<" enter the value of x";
cin>>x;
cout<<" enter the value of y";
cin>>y;
cout<<" enter the value of z";
cin>>z;
r = (sqrt(pow(x,2) + pow(y, 2) + pow(z, 2)));
phi = (asinf(y/r)*180.0f)/PI;
theta = (asinf(-x/(r*cosf(phi)))*180.0f)/PI;
cout<<"The radius r= "<<r;
cout<<"The phi angle= "<<phi;
cout<<"The theta angle= "<<theta;
return 0;
}