+ 3
How do you use square root in a code? on c++
a code displaying sort and comments will be helpful thAnks
3 Answers
+ 2
You posting the language you want it in would also be helpful :)
Since I see that you only have C++ as a course I'll just assume you want it in C++
#include <iostream>
#include <cmath> // For sqrt
int main()
{
std::cout << sqrt(5);
}
+ 6
In Python and all languages where you have an exponentiation operator, it's sufficient to go like:
print(x**.5) # meaning x to the power of œ
+ 1
Math.sqrt() in JS
https://code.sololearn.com/WP13fWMelH4x/?ref=app