Download presentation
Presentation is loading. Please wait.
1
Decisions & Flows
2
If if ( condition ) statement if (s.gpa <= 1.0) expel(s); if (x<y)// then swap x,y {x += y; y = x-y; x = x-y; };
3
Relational Operators >, < ==// = !=// >=// <=//
4
Pitfalls Warnings: “=“ “==“ Comparing reals: precision
5
Or Else if ( condition ) statement1 else statement 2; if (x<y)// set min(x,y)=0 {x=0;// & set z=max(x,y) z=y; } else {y=0; z=x; }
6
Conditions if ( not taken(cs113) or grade<=2 ) take(cs113); if ( ! taken(cs113) || grade<=2 ) take(cs113); Both mean the same First easier to read Second easier to “parse”
7
More conditions if ( not (confused or lost) and awake ) congratulations; else if ( done(hw1) and bored ) apologies; else warning;
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.