3.04-while練習3

/*

題目:計算1~100中所有3的倍數的個數

*/


#include <stdio.h>


int main()

{

    // 記錄3的倍數的個數

    int count = 0;

    

    // 記錄當前檢查的數值

    int number = 0;

    

    while (number < 100)

    {

        number++;

        

        // 說明number3的倍數

        if (number%3 == 0)

        {

            count++;

        }

    }

    

    printf("1~1003的倍數的個數:%d\n", count);

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章