这是在c++中,在c语言中使用函数sqrt时头文件是<math.h>
直接上代码:
#include<iostream>
#include<cmath>
#include<Windows.h>
using namespace std;
int main3(void) {
double a;
double c;
cin >> a;
c = sqrt(a);//求a的算数平方根
cout << c << endl;
system("pause");
return 0;
}
在这里需要注意:
使用函数sqrt时,a与c都必须是浮点类型的变量,否则,编译器就会报错