Created
April 2, 2019 14:08
-
-
Save vixtory09678/8ce9e176403bc5ecc7c01e433fa7cb3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int age = 20; | |
// แบบ 1 | |
if (age > 50) { | |
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไขเป็นจริง | |
} | |
// แบบ 2 | |
if (age > 50) { | |
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไขเป็นจริง | |
} else { | |
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไขไม่เป็นจริง | |
} | |
// แบบ 3 | |
if (age > 50) { | |
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไข age > 50 เป็นจริง ถ้าไม่เป็นจริงไปเช็คเงื่อนไขถัดไป | |
} else if (age > 25) { | |
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไข age > 25 เป็นจริง ถ้าไม่เป็นจริงไปเช็คเงื่อนไขถัดไป | |
} else if (age > 15) { | |
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไข age > 15 เป็นจริง ถ้าไม่เป็นจริงไปเช็คเงื่อนไขถัดไป | |
} else { | |
// ส่วนที่เอาไว้เขียนว่าจะให้ทำอะไรถ้าเงื่อนไขใด ๆ ไม่เป็นจริง | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment