8-IfElse

# 8-IfElse - ControlStructures DecisionMakingwith IF Control...

This preview shows pages 1–8. Sign up to view the full content.

Control Structures: Decision Making with IF

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

View Full Document
Control Structures C statements can make decisions via Selection structures The if selection statement performs (selects) an action if a condition is true skips the action if the condition is false . The if else selection statement performs an action if a condition is true performs a different action if the condition is false . The switch selection statement performs one of many different actions depending on the value of an expression.
Decision Making: Equality and Relational Operators Example: determine if a person’s grade on an exam is greater than or equal to 60 if it is, print the message “passed.”

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

View Full Document
Control Structures (Cont.) FLOW CHARTS for Selection Structures: The diamond symbol , also called the decision symbol, indicates that a decision is to be made. Condition true? Action (s) to take if true
The if Selection Statement C syntax: if (condition) { /* begin condition*/ stmnt 1; stmnt 2; …. } /* end condition */ Condition true? Action (s) to take if true CS211 Rule: Line up the brackets and provide comments!

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

View Full Document
Conditional Operators for IF  and other conditional statements if  ( grade >=  60  )
The if Selection Statement

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 25

8-IfElse - ControlStructures DecisionMakingwith IF Control...

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

View Full Document
Ask a homework question - tutors are online