我只是编写一个程序来计算整数的幂.但产量不如预期.除了5的幂之外,它适用于所有整数.
我的代码是:
#include <stdio.h>
#include <math.h>
int main(void)
{
int a,b;
printf("Enter the number.");
scanf("\n%d",&a);
b=pow(a,2);
printf("\n%d",b);
}
Run Code Online (Sandbox Code Playgroud)
输出是这样的:
"Enter the number. 2
4
"Enter the number. 5
24
"Enter the number. 4
16
"Enter the number. 10
99
Run Code Online (Sandbox Code Playgroud)
我们不能使用pow()int数据类型的函数??