Advertisement
Guest User

C++ quadratic formula

a guest
Sep 30th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. int main()
  5. {
  6.  
  7.     double a, b, c, x1, x2;
  8.     std::cout<<"Helloworld"<<std::endl;
  9.  
  10.     a=2.00;
  11.     b=8.00;
  12.     c=6.00;
  13.        
  14.     std::cout<<"Heres the quadratic formula:"<<std::endl;
  15.     std::cout<<a<<"x^2"<<'+'<<b<<'x'<<'+'<<c<<endl;
  16.    
  17.     x1=b+(sqrt(pow(b, 2)-4*a*c))/(2*a);
  18.     x2=-b+(sqrt(pow(b, 2)-4*a*c))/(2*a);
  19.  
  20.     std::cout<<x1<<" or"<<x2<<endl;
  21.  
  22.     return EXIT_SUCCESS;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement