$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
if else statement
Search
Nedval
October 18, 2016
0
55
if else statement
Nedval
October 18, 2016
Tweet
Share
More Decks by Nedval
See All by Nedval
C 程式語言 I
nedval
0
110
軟體測試與驗證—CI & CU
nedval
0
84
SQL Intro
nedval
0
100
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
14k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
60
37k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
57
37k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.1k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
400
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
33
First, design no harm
axbom
PRO
1
1.1k
The Cult of Friendly URLs
andyhume
79
6.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.3k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1k
Transcript
IF ELSE STATEMENT by
[email protected]
if ( 邏輯運算式 ) { /* 運算結果為真(條件成立)時, 須執行的程式 */ }
在這之前,需要先認識一個東西 …
None
杯緣子
運算子 + - * / (operator )
算術運算子 + - * /
杯緣子的好朋友叫做 …
杯緣子的好朋友叫做 杯緣
運算子的好朋友叫做 …
運算子的好朋友叫做 運算元(operand)
int e7; e7 = 8 + 9;
int e7; e7 = 8 + 9; 運算子(operator)
int e7; e7 = 8 + 9; 運算元(operand)
if 條件陳述中常用的運算子 && 而且 || 或者 == 等於 != 不等於
<= 小於等於 >= 大於等於 < 小於 > 大於
if 條件陳述中常用的運算子 邏輯 && 而且 || 或者 == 等於 !=
不等於 <= 小於等於 >= 大於等於 < 小於 > 大於
if 條件陳述中常用的運算子 邏輯 && 而且 || 或者 == 等於 !=
不等於 <= 小於等於 >= 大於等於 < 小於 > 大於 個人偏好在程式中 只使用 <= 和 < 不使用 >= 和 > 因為寫起來的順序 與數線相同 較容易閱讀
0 <= < 右大 左小
練習將文字說明改成程式碼
如果氣溫超過 26 度 C,則可以開冷氣,否則不能開。
如果氣溫超過 26 度 C,則可以開冷氣,否則不能開。 if
如果氣溫超過 26 度 C,則可以開冷氣,否則不能開。 26 < temperature
如果氣溫超過 26 度 C,則可以開冷氣,否則不能開。 26 < temperature 邏輯運算子
如果氣溫超過 26 度 C,則可以開冷氣,否則不能開。 26 < temperature 運算元 運算元
if (26 < temperature ) { } 邏輯運算式
如果氣溫超過 26 度 C,則可以開冷氣,否則不能開。 條件成立的結果
if (26 < temperature ) { printf("可以開冷氣"); }
如果氣溫超過 26 度 C,則可以開冷氣,否則不能開。
if (26 < temperature ) { printf("可以開冷氣"); } else {
}
如果氣溫超過 26 度 C,則可以開冷氣,否則不能開。 條件不成立的結果
if (26 < temperature ) { printf("可以開冷氣"); } else {
printf("不能開冷氣"); }
int temperature; printf("請輸入現在溫度(°C): "); scanf("%d", &temperature); if (26 < temperature
) { printf("可以開冷氣"); } else { printf("不能開冷氣"); }
//宣告一個名字為 temperature 的空間用來存放溫度的值 int temperature; //提示使用者輸入溫度 printf("請輸入現在溫度(°C): "); //讀取使用者輸入的溫度並存放到 temperature
的空間 scanf(“%d”, &temperature); if (26 < temperature ) { // 若溫度大於 26 度則顯示可以開冷氣 printf(“可以開冷氣”); } else { // 若溫度沒有大於 26 度則顯示不能開冷氣 printf("不能開冷氣"); }