c - 使用cygwin终端在c中打印数字的幂

标签 c cygwin type-conversion

我无法在以下程序中找到 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。

最佳答案

232 等于 4294967296。这很容易被 long long 类型反感。使用 %lld 说明符。

关于c - 使用cygwin终端在c中打印数字的幂,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21799699/

相关文章:

java - 如何在 Windows 上从 Java 生成 bash 脚本?

c++ - 使用 Cygwin 编译 Corkscrew 时出现配置错误

windows - 用于与 Windows 命名管道通信的程序

swift - FloatingPoint 扩展 - 使用其他 FloatingPoint 类型初始化

python - boolean 值与 float 相乘?

在 C 中复制对数组的引用

C 打印数组的元素

c - 当我尝试在 Eclipse CDT 中运行程序时,我的可执行文件停止运行

c - 解释使用链表实现的栈的输出

c - C 中的隐式类型转换