Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. float a,b,c,x1,x2;
  9.  
  10. cout<<"type a: ";
  11. cin>>a;
  12. cout<<"type b: ";
  13. cin>>b;
  14. cout<<"type c: ";
  15. cin>>c;
  16.  
  17. if(b*b - 4*a*c<0)
  18. cout<<"There is no solution.";
  19. if(b*b - 4*a*c==0)
  20. {
  21. x1= (-b - sqrt(b*b - 4*a*c))/2*a;
  22. cout<<"There is one solution"<<x1;
  23. }
  24. else
  25. {
  26. x1= (-b - sqrt(b*b - 4*a*c))/2*a;
  27. x2= (-b + sqrt(b*b - 4*a*c))/2*a;
  28. cout<<"There is 2 solutions \n"<<x1<<endl<<x2<<endl;
  29. }
  30.  
  31.  
  32.  
  33. system("pause");
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement