Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <math.h>
- using namespace std;
- int main()
- {
- float a,b,c,x1,x2;
- cout<<"type a: ";
- cin>>a;
- cout<<"type b: ";
- cin>>b;
- cout<<"type c: ";
- cin>>c;
- if(b*b - 4*a*c<0)
- cout<<"There is no solution.";
- if(b*b - 4*a*c==0)
- {
- x1= (-b - sqrt(b*b - 4*a*c))/2*a;
- cout<<"There is one solution"<<x1;
- }
- else
- {
- x1= (-b - sqrt(b*b - 4*a*c))/2*a;
- x2= (-b + sqrt(b*b - 4*a*c))/2*a;
- cout<<"There is 2 solutions \n"<<x1<<endl<<x2<<endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement