下列 C 程式迴圈執行完畢後,變數 count 的值為何?#include<stdio.h> int i; int count=1; int main(){ for (i=1; i <= 10; i++){ if(i%5 == 0) break; count *= (i+1); printf("%d\n", count); } printf("%d", count); return 0; }
A120正確答案
B39916800
C3628800
D24
答案與詳解
i=1: count=1*2=2;i=2: count=2*3=6;i=3: count=6*4=24;i=4: count=24*5=120;i=5: i%5==0 觸發 break 跳出,count 保持 120。
