C语言pow函数的用法是什么?

t", pow(i,3));printf("%ld\t", (long)pow((int)i,3));printf("结果是:%I64d\t",(long long int )pow(i,3));printf("%d\n", (int)pow(i,3));system("pause");f(i);system("pause");}这个程序为什么只有前一个输出答案正确,后面的都不正确呢?

1,要加入头文件 math.h
2,pow(x,y);//其作用是计算x的y次方。x、y及函数值都是double型
例:
我要计算2的5次方
源代码如下:
#include"stdio.h"
#include"math.h"
main()
{
long total;
int x = 2, y = 5;
total = pow(x,y); /*调用pow函数*/
printf("%ld",total);
getch();
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-03-09
原型:extern float pow(float x, float y);

用法:#include <math.h>

功能:计算x的y次幂。

说明:x应大于零,返回幂指数的结果。

举例:

// pow.c

#include <syslib.h>

#include <math.h>

main()

{

clrscr(); // clear screen

textmode(0x00); // 6 lines per LCD screen

printf("4^5=%f",pow(4.,5.));

getchar();

return 0;

}
第2个回答  2018-03-09
原型:extern float pow(float x, float y);

用法:#include <math.h>

功能:计算x的y次幂。

说明:x应大于零,返回幂指数的结果。

举例:

// pow.c

#include <syslib.h>

#include <math.h>

main()

{

clrscr(); // clear screen

textmode(0x00); // 6 lines per LCD screen

printf("4^5=%f",pow(4.,5.));

getchar();

return 0;

}