我无法在以下程序中找到 2 的 32 次方的精确解。我正在使用 cygwin 终端。
#include <stdio.h>
main()
{
int base, expo;
long long value = 1;
printf("Enter base number and exponent respectively");
scanf("%d%d", &base, &expo);
while (expo != 0)
{
value *= base;
--expo;
}
printf("Answer = %ll ", value);
return 0;
}
我需要一些帮助来了解哪种数据类型适合将 2 的值存储为 32。
最佳答案
2
32
等于 4294967296
。这很容易被 long long
类型反感。使用 %lld
说明符。
关于c - 使用cygwin终端在c中打印数字的幂,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21799699/