<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # C 程序:計算數字的冪 > 原文: [https://www.programiz.com/c-programming/examples/power-number](https://www.programiz.com/c-programming/examples/power-number) #### 在此示例中,您將學習計算數字的冪。 要理解此示例,您應該了解以下 [C 編程](/c-programming "C tutorial")主題: * [C 編程運算符](/c-programming/c-operators) * [C `while`和`do...while`循環](/c-programming/c-do-while-loops) * * * 下面的程序從用戶那里獲取兩個整數(一個基數和一個指數)并計算功效。 例如:對于`2 ^ 3` * 2 是基數 * 3 是指數 * 并且,冪等于`2*2*2` * * * ## 使用`while`循環的數字冪 ```c #include <stdio.h> int main() { int base, exp; long long result = 1; printf("Enter a base number: "); scanf("%d", &base); printf("Enter an exponent: "); scanf("%d", &exp); while (exp != 0) { result *= base; --exp; } printf("Answer = %lld", result); return 0; } ``` **輸出** ```c Enter a base number: 3 Enter an exponent: 4 Answer = 81 ``` 僅當指數為**正整數**時,以上技術才有效。 如果需要找到具有任何實數的冪的冪,可以使用`pow()`函數。 * * * ## 使用`pow()`函數的冪 ```c #include <math.h> #include <stdio.h> int main() { double base, exp, result; printf("Enter a base number: "); scanf("%lf", &base); printf("Enter an exponent: "); scanf("%lf", &exp); // calculates the power result = pow(base, exp); printf("%.1lf^%.1lf = %.2lf", base, exp, result); return 0; } ``` **輸出** ```c Enter a base number: 2.3 Enter an exponent: 4.5 2.3^4.5 = 42.44 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看