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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # C 程序:查找商和余數 > 原文: [https://beginnersbook.com/2017/09/c-program-to-find-quotient-and-remainder/](https://beginnersbook.com/2017/09/c-program-to-find-quotient-and-remainder/) 程序根據用戶輸入的被除數和除數查找**商**和**余數**。 ## 示例 1:用于查找商和余數的程序 在該程序中,要求用戶輸入被除數和除數,然后程序根據輸入值查找商和余數。 ```c #include <stdio.h> int main(){ int num1, num2, quot, rem; printf("Enter dividend: "); scanf("%d", &num1); printf("Enter divisor: "); scanf("%d", &num2); /* The "/" Arithmetic operator returns the quotient * Here the num1 is divided by num2 and the quotient * is assigned to the variable quot */ quot = num1 / num2; /* The modulus operator "%" returns the remainder after * dividing num1 by num2. */ rem = num1 % num2; printf("Quotient is: %d\n", quot); printf("Remainder is: %d", rem); return 0; } ``` 輸出: ```c Enter dividend: 15 Enter divisor: 2 Quotient is: 7 Remainder is: 1 ``` ## 示例 2:使用函數查找商和余數的程序 在這個程序中,我們正在做上述程序的相同的事情,但是在這里我們使用函數來查找商和余數。我們為計算創建了兩個用戶定義的函數。要理解這個程序,您應該對以下 [C 編程](https://beginnersbook.com/2014/01/c-tutorial-for-beginners-with-examples/)主題有基本的了解: 1. [C 中的函數](https://beginnersbook.com/2014/01/c-functions-examples/) 2. [C 中的按值函數調用](https://beginnersbook.com/2014/01/c-function-call-by-value-example/) ```c #include <stdio.h> // Function to computer quotient int quotient(int a, int b){ return a / b; } // Function to computer remainder int remainder(int a, int b){ return a % b; } int main(){ int num1, num2, quot, rem; printf("Enter dividend: ");? ? scanf("%d", &num1); printf("Enter divisor: ");? ? scanf("%d", &num2); //Calling function quotient()? ? quot = quotient(num1, num2); //Calling function remainder()? ? rem = remainder(num1, num2); printf("Quotient is: %d\n", quot);? ? printf("Remainder is: %d", rem); return 0; } ``` 查看相關的 [C 程序](https://beginnersbook.com/2015/02/simple-c-programs/): 1. [C 程序:相加兩個數字](https://beginnersbook.com/2017/09/c-program-to-add-two-numbers/) 2. [C 程序:相乘兩個浮點數](https://beginnersbook.com/2017/09/c-program-to-multiply-two-floating-point-numbers/) 3. [C 程序:查找字符的 ASCII 值](https://beginnersbook.com/2017/09/c-program-to-find-ascii-value-of-a-character/) 4. [C 程序:計算并打印 nCr](https://beginnersbook.com/2015/02/c-program-to-calculate-and-print-the-value-of-ncr/) 的值
                  <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>

                              哎呀哎呀视频在线观看