<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # C 程序:將二進制數轉換為十進制數 > 原文: [https://beginnersbook.com/2015/02/c-program-to-convert-binary-number-to-decimal-number/](https://beginnersbook.com/2015/02/c-program-to-convert-binary-number-to-decimal-number/) 該程序將二進制數轉換為等效的十進制數。 ## 示例:將二進制轉換為十進制的程序 在這個程序中,我們創建了一個用戶定義的函數`binaryToDecimal()`,用于二進制到十進制的轉換。該程序將二進制數(由用戶輸入)作為輸入,并使用函數將其轉換為十進制數。要理解這個程序,您應該熟悉以下 [C 編程](https://beginnersbook.com/2014/01/c-tutorial-for-beginners-with-examples/)的概念: 1. [C 中的用戶定義函數](https://beginnersbook.com/2014/01/c-functions-examples/) 2. [C `while`循環(https://beginnersbook.com/2014/01/c-while-loop/) ```c #include <stdio.h> #include <math.h> int binaryToDecimal(long binarynum) { int decimalnum = 0, temp = 0, remainder; while (binarynum!=0) { remainder = binarynum % 10; binarynum = binarynum / 10; decimalnum = decimalnum + remainder*pow(2,temp); temp++; } return decimalnum; } int main() { long binarynum; printf("Enter a binary number: "); scanf("%ld", &binarynum); printf("Equivalent decimal number is: %d", binaryToDecimal(binarynum)); return 0; } ``` 輸出: ```c Enter a binary number: 1010111 Equivalent decimal number is: 87 ``` 看看這些相關的 C 程序: 1. [C 程序:將十進制數轉換為八進制](https://beginnersbook.com/2017/09/c-program-to-convert-decimal-to-octal-number/) 2. [C 程序:將八進制數轉換為十進制數](https://beginnersbook.com/2017/09/c-program-to-convert-octal-number-to-decimal-number/) 3. [C 程序:將八進制數轉換為二進制數](https://beginnersbook.com/2017/09/c-program-to-convert-octal-number-to-binary-number/) 4. [C 程序:將二進制數轉換為八進制](https://beginnersbook.com/2017/09/c-program-to-convert-binary-to-octal-number-system/) 5. [C 程序:將小寫字符串轉換為大寫](https://beginnersbook.com/2015/02/c-program-to-convert-lowercase-string-to-uppercase-string/)
                  <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>

                              哎呀哎呀视频在线观看