Control Flow Control flow Control flow 4 Sequencing

  • Slides: 15
Download presentation
Control Flow

Control Flow

Control flow • Control flow ของภาษาใชสำหรบกำหนดขนตอนการคำนวณ แบงออกได 4 กลมดงน – Sequencing – Conditional –

Control flow • Control flow ของภาษาใชสำหรบกำหนดขนตอนการคำนวณ แบงออกได 4 กลมดงน – Sequencing – Conditional – Selection – Looping (or iterative processing)

Statements and Blocks • ในภาษา C ใชเครองหมาย statement • Simple statement lower = 0;

Statements and Blocks • ในภาษา C ใชเครองหมาย statement • Simple statement lower = 0; upper = 300; step = 20; • Null Statement ? ; (semicolon) บอกจดสนสด

Statements and Blocks • Compound Statements (block statements) { celsius = (5. 0/9. 0)

Statements and Blocks • Compound Statements (block statements) { celsius = (5. 0/9. 0) * (fahr-32. 0); printf("%3. 0 f %6. 1 fn", fahr, celsius); fahr = fahr + step; } • compound-statement : { declaration-listopt statement-listopt }

Shortcut if(expression). . . if(expression ? ? 0). . .

Shortcut if(expression). . . if(expression ? ? 0). . .

Else-If Statement if (expression) statement else option statement

Else-If Statement if (expression) statement else option statement