小编bas*_*nta的帖子

pow()是否适用于C中的int数据类型?

我只是编写一个程序来计算整数的幂.但产量不如预期.除了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数据类型的函数??

c exponentiation pow

14
推荐指数
1
解决办法
3万
查看次数

标签 统计

c ×1

exponentiation ×1

pow ×1