Tag: 幂数

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

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