c语言中pow的用法
时间:
长思709由 分享
c语言中pow的用法
c语言中pow的用法的用法你知道吗?下面小编就跟你们详细介绍下c语言中pow的用法的用法,希望对你们有用。
c语言中pow的用法的用法如下:
原型:extern float pow(float x, float y);
学习啦在线学习网 用法:#include
功能:计算x的y次幂。
说明:x应大于零,返回幂指数的结果。
举例:
学习啦在线学习网 // pow.c
#include
学习啦在线学习网 #include
#include
学习啦在线学习网 void main()
{
printf("4^5=%f",pow(4.,5.));
getchar();
}
学习啦在线学习网 #include
学习啦在线学习网 #include
学习啦在线学习网 void main( void )
{
学习啦在线学习网 double x = 2.0, y = 3.0, z;
z = pow( x, y );
学习啦在线学习网 printf( "%.1f to the power of %.1f is %.1f ", x, y, z );
}
Output
2.0 to the power of 3.0 is 8.0