900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > c语言如何打根号 – CSS – 前端 html代码 css程序

c语言如何打根号 – CSS – 前端 html代码 css程序

时间:2018-09-05 02:33:18

相关推荐

c语言如何打根号 – CSS – 前端 html代码 css程序

c语言中没有根号。

首先在 main()函数 上边加个#include "math.h" 因为开根号属于 数学函数里边的函数,要使用根号就要加上#inculde "math.h",

然后在你要开根号的数的前边加个 sqrt,就可以了

例如

#inculde "math.h"

main()

{ float a,b;

printf("please input a nuberm:");

scanf("%f",&a);

b=sqrt(a);

printf("%f\n",b);}这个程序就是 让 用户输入个数字,然后输出原数值的开根号后的结果

例:

#include <math.h>

#include <stdio.h>

int main(void)

{double x = 4.0, result;

result = sqrt(x);

printf("The square root of %lf is %lf

", x, result);

return 0;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。