Skip to content

Commit

Permalink
sqrt() -> std::sqrt
Browse files Browse the repository at this point in the history
`std::sqrt()` should be used instead of just `sqrt()` because `<cmath>` doesn't necessarily provide `sqrt()` in the global namespace.
  • Loading branch information
sonnynomnom authored Mar 25, 2019
1 parent 3544ec6 commit 97ff74d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 2-variables/quadratic-formula/quadratic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ int main() {
std::cout << "Enter c: ";
std::cin >> c;

root1 = (-b + sqrt(b*b - 4*a*c)) / (2*a);
root2 = (-b - sqrt(b*b - 4*a*c)) / (2*a);
root1 = (-b + std::sqrt(b*b - 4*a*c)) / (2*a);
root2 = (-b - std::sqrt(b*b - 4*a*c)) / (2*a);

std::cout << "Root 1 is " << root1 << "\n";
std::cout << "Root 2 is " << root2 << "\n";
Expand Down

0 comments on commit 97ff74d

Please sign in to comment.