晨曦到日暮 发表于 2018-1-9 19:34:27

C语言

8.编写程序,输入一正实数,输出它的平方根。
#include<stdio.h>
int main()
{
        int a;
        double b;
        printf("请输入一个正整数:");
        scanf("%d",&a);
        b=sqrt(a);
        printf("它的平方根是:%d",&b);
        return 0;
}

G:\新建文件夹\第八题.cpp(8) : error C2065: 'sqrt' : undeclared identifier

人造人 发表于 2018-1-9 19:37:09

https://baike.so.com/doc/6341242-6554858.html

BngThea 发表于 2018-1-9 21:52:05

加入头文件
#include <math.h>
页: [1]
查看完整版本: C语言