Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decisions & Flows. 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; };

Similar presentations


Presentation on theme: "Decisions & Flows. 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; };"— Presentation transcript:

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;


Download ppt "Decisions & Flows. 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; };"

Similar presentations


Ads by Google