Download presentation
Presentation is loading. Please wait.
Published byGarey Arthur Chase Modified over 8 years ago
1
CSI 3125, Preliminaries, page 1 Control Statements
2
CSI 3125, Preliminaries, page 2 Control Statements to control the flow of execution of program control statements can be put into the following categories: selection, iteration, and jump. Selection statements allow program to choose different paths of execution Iteration statements enable program execution to repeat one or more statements. Jump statements allow program to execute in a nonlinear fashion.
3
CSI 3125, Preliminaries, page 3 Selection Statements If statement if else statement nested statement if –else-if ladder
4
CSI 3125, Preliminaries, page 4 Selection Statements if else statement Syntax if(condition) { true block statements; } else { false block statements; }
5
CSI 3125, Preliminaries, page 5 Selection Statements Nested if statement Syntax if(condition1) { if (condition2) { true block statements 2; } else { false block statements 2; }
6
CSI 3125, Preliminaries, page 6 Selection Statements If-else- ladder statement Syntax if(condition1) { true blck statements 1;; } else if(condition 2) { true block statements 2; }
7
CSI 3125, Preliminaries, page 7 Switch Statements Multiway branch statement. general form switch (expression) { case value1: // statement sequence break; case value2: // statement sequence break;... case valueN: // statement sequence break; default: // default statement sequence }
8
CSI 3125, Preliminaries, page 8 Iteration Statements while for do-while nested loop
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.