Advertisement
Guest User

First ever program in C++!

a guest
Dec 11th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int main() {
  5. double a;
  6. double b;
  7. double c;
  8.  
  9. std::cout << "Enter a: ";
  10. std::cin >> a;
  11. std::cout << "Enter b: ";
  12. std::cin >> b;
  13. std::cout << "Enter c: ";
  14. std::cin >> c;
  15.  
  16. double root1;
  17. double root2;
  18.  
  19. root1 = (-b + std::sqrt (b*b - 4*a*c)) / (2*a);
  20. root2 = (-b - std::sqrt (b*b - 4*a*c)) / (2*a);
  21.  
  22. std::cout << "Root 1 Is " << root1 << "\n";
  23. std::cout << "Root 2 Is " << root2 << "\n";
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement