此函数查找给定数字的平方根。
square_root of a number=√arg
double sqrt(double arg); float sqrt(float arg); long double sqrt(long double arg); double sqrt(integral arg);
arg : 它是float或整数类型的值。
它返回参数arg的平方根。
让我们看一个简单的示例,其中参数" arg"为整数类型。
#include <iostream> #include<cmath> using namespace std; int main() { int arg=16; std::cout << "Square root of a number is :" <<sqrt(arg); return 0; }
输出:
Square root of a number is :
让我们看一个简单的示例,其中参数" arg"为浮点类型
#include <iostream> #include<cmath> using namespace std; int main() { float arg=8.5; std::cout << "Square root of a number is :" <<sqrt(arg); return 0; }
输出:
Square root of a number is :2.91548
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)