208 Day 05 Selection

208 Day 05 Selection - 4002-208Intro. to Prog. [in C++]Day

Info iconThis preview shows pages 1–8. 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

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: 4002-208Intro. to Prog. [in C++]Day 05SelectionObjectivesBasic if statementRelational conditionsNested if statementsLogical conditions24002-208Uses of if StatementAlgorithmUsed in algorithm to compute correct values.Data validationtest input values to ensure the value satisfies prescribed conditions. Invalid data can cause a program to crash or produce incorrect results. 34002-208ExampleEnglishIf the sun is shining, we will go to the beach;otherwise we will go to the bowling alley.Pseudo-Englishif (sun is shining)go to beachelsego to bowling alley44002-208Relational OperatorsA condition must be written so that it can be evaluated as true or false.Logical operators: <less than<=less than or equal to>greater than>= greater than or equal to==equal to!=not equal to54002-208if/else Statementif (condition){block of code to be executed if condition is true}else{block of code to be executed if condition is false}//continue execution here64002-208Exampleif ( age >= 21 )...
View Full Document

This note was uploaded on 03/31/2009 for the course NSSA 4002 208 taught by Professor Niemi during the Spring '09 term at RIT.

Page1 / 17

208 Day 05 Selection - 4002-208Intro. to Prog. [in C++]Day

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

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