if else ifscore 1000 bouns 0 else if
Sign up to view full document!
SIGN UP
if…. else敘述 if(score <1000) bouns = 0; else if (score<1500) bouns =1; else if (score<2000) bouns = 2; else if (score<2500) bouns = 4; else bouns = 6;
if(condition) do this; else會和最 else 接近的if配 do this; 對 if(condition) { do this; if(contion) do this; } else do this; 因為大括號 將在內部的 if敘述括起 來,所以 else跟第一 個if配對
if(number>6) { if(number<12) printf("You're close!n"); } else printf("Sorry, you lose a turn!n"); 數字 回應 5 10 15 Sorry, you lose a turn! You’re close! 沒回應
Switch使用和不使用break敘述的 程式流程 switch(number) { { case 1: statment 1; break; case 2: statment 2; break; case 3: statment 3; break; default: statment 4; } statment 5; case 2: statment 2; case 3: statment 3; default: statment 4; } statment 5;
- Slides: 16