Download presentation
Presentation is loading. Please wait.
Published byChristine Johns Modified over 9 years ago
1
3.3.3.3. ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures
2
2 && Operator (logical AND opterator) && is a boolean operator, so the value of an expression is true or false. ( cond1 && cond2 ) is true only if both cond1 and cond2 are true. 0 9/ 2 0 1 4
3
3 || Operator (logical OR operator) || is a boolean operator, so the value of an expression is true or false. ( cond1 || cond2 ) is true if either of cond1 or cond2 is true. 0 9/ 2 0 1 4
4
4 The ! operator (logical NOT operator) The ! operator is a unary boolean operator unary means it has only 1 operand. ! negates it's operand. ! means "not". (! condition) is true only when condition is false 0 9/ 2 0 1 4
5
5 5 [ Practice 01 logical operator ]
6
6 6 [ Explain 01 logical operator ]
7
7 09 /2 01 4 if structure The if control structure allows us to state that an action (sequence of statements) should happen only when some condition is true: if (condition ) action;
8
8 8 [ Practice 02 if ]
9
9 9 [ Explain 02 if ]
10
10 09 /2 01 4 if else structure The if else control structure allows you to specify an alternative action: if ( condition ) action if true else action if false
11
11 [ Practice 03 if else ]
12
12 [ Explain 03 if else ]
13
13 Syntax switch (expression) { case const-expr : statements; break; case const-expr : statements; break; … default statements; break; } 09 /2 01 4 switch statement
14
14 [ Practice 04 switch ]
15
15 [ Explain 04 switch ] 0 ≦ code ≦ 4
16
16 09 /2 01 4 while Control Structure The while control structure supports repetition - the same statement (or compound statement) is repeated until the condition is false. while (condition) do something; the inside is calledthe inside is called the "body of the loop"the "body of the loop"
17
17 [ Practice 05 while ]
18
18 [ Explain 05 while ]
19
19 09 /2 01 4 do while The do while control structure also provides repetition, this time the condition is at the bottom of the loop. the body is always executed at least once do somestuff ; while ( condition );
20
20 [ Practice 06 do while ]
21
21 [ Explain 06 do while ]
22
22 09 /2 01 4 for loops The for control structure is often used for loops that involve counting. You can write any for loop as a while (and any while as a for). for (initialization; condition; update) do something;
23
23 [ Practice 07 for ]
24
24 [ Explain 07 for ]
25
Thank you
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.