1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 【C语言】开平方公式 根号下x的函数使用:sqrt()

【C语言】开平方公式 根号下x的函数使用:sqrt()

时间:2018-11-07 22:10:32

相关推荐

【C语言】开平方公式 根号下x的函数使用:sqrt()

使用方法:

#include <math.h>

a = sqrt(b);

注意:

1. sqrt()函数是向下取整,即sqrt(10)=3

2. 浮点型使用sqrt()后,输出结果为int整数型

代码实例:

#include <stdio.h>#include <math.h>int main(){int a1,a2,b;double c;b = 10;c = 10.0;//sqrt() 需要添加:#include <math.h>a1 = sqrt(b);//a1=3,向下取整a2 = sqrt(c);//a2=3,向下取整且强制转化为int型printf("a1:%d\n",a1);//3printf("a2:%d\n",a2);//3}

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