Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. int main()
  2. {
  3. int a, b, c, d;
  4.  
  5. cout << "Enter the value of coefficient a: ";
  6. cin >> a;
  7.  
  8. if (a == 0)
  9. {
  10. cout << "Error! The value of a is 0!\n";
  11. return 0;
  12. }
  13. else
  14. {
  15. cout << "Enter the value of coefficient b: ";
  16. cin >> b;
  17.  
  18. cout << "Enter the value of coefficient c: ";
  19. cin >> c;
  20. }
  21.  
  22. d = b * b - 4 * a * c;
  23.  
  24. if (d < 0)
  25. {
  26. cout << "No real roots!\n";
  27. return 0;
  28. }
  29. else
  30. {
  31. cout <<"Real root 1: " <<(-b + d) / (2 * a) << endl;
  32. cout <<"Real root 2: " <<(-b - d) / (2 * a) << endl;
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement