20 DecisionStructures

20 DecisionStructures - July 07 Kamal B. Rojiani 1 Control...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: July 07 Kamal B. Rojiani 1 Control Structures: Selection CEE 3804 Computer Applications for CEE Kamal B. Rojiani 2 Selection circle6 Program lines are executed in sequence circle6 We want to change this order of execution circle6 Select alternative computational paths circle6 Perform the same task several times Kamal B. Rojiani 3 If /Then Statement If < condition > Then < Basic statements > EndIf circle6 condition is a logical expression that consists of two quantities to be compared and a relational operator < quantity 1 > rel oper < quantity 2 > If y < 3 Then z = y + 6 End If If z > 0 Then y = Math.Sqrt(z) End If Kamal B. Rojiani 4 Relational Operators Operator Meaning < Less than > Greater than = Equal to <= or =< Less than or equal to >= or => Greater than or equal to <> Not equal to circle6 The result of the comparison is True or False x < 0 x + y < z x >= 0 x + y > 2 * z Kamal B. Rojiani 5 If/Then/Else Statement If < condition > Then < true alternative statement > Else < false alternative statement > EndIf If x <= 0 Then y= a * 2.5 + 200.5 Else y = Math.Sqrt(2! * x + 6!) End If Kamal B. RojianiKamal B....
View Full Document

This note was uploaded on 11/14/2008 for the course CEE 3804 taught by Professor Aatrani during the Fall '07 term at Virginia Tech.

Page1 / 13

20 DecisionStructures - July 07 Kamal B. Rojiani 1 Control...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online