Interactive Application Development - Branching the Program Flow with C# PDF

Document Details

Uploaded by Deleted User

Sheridan College

2025

Shalini Singh Jaspal

Tags

c# programming program flow control structures computer science

Summary

This document is lecture notes for a computer science course titled "Interactive Application Development", focusing on branching program flow using C#. The document includes examples and learning outcomes.

Full Transcript

Interactive Application Development Branching the Program Flow with C# Shalini Singh Jaspal [email protected] Winter 2025 Copyright, Magdin Stoica, Sheridan College May not be published...

Interactive Application Development Branching the Program Flow with C# Shalini Singh Jaspal [email protected] Winter 2025 Copyright, Magdin Stoica, Sheridan College May not be published or modified without permission. Learning Outcomes  Define control structures using if-else statement and multi- branch program flows with if-else-if  Identify typical errors involving the use of if statements  Describe best practices used when writing if statements  Define multi-branch control structure using the switch statement  Explain the use of fall through cases in switch statements  Identify typical errors involving the use of switch statements  Create programs whose flow is branched using if and switch statements. Interactive Application Development – Winter 2025 1 A fork in the road Positive outcome: what happens if the condition is “true” 1. Balance decreases 2. Money Account dispensed has … … sufficient funds 1. User is informed of insufficient funds Negative outcome: The condition what happens if the condition is “false” Interactive Application Development – Winter 2025 2 If / Else Control Structure Keyword to introduce the The condition condition if () ; else ; Keyword to “else” may be missing if no introduce the negative outcome is negative outcome needed Interactive Application Development – Winter 2025 3 If Statement (without an else) Keyword to introduce the The condition condition if () ; “else” is missing if no negative outcome is needed Interactive Application Development – Winter 2025 4 If / Else Statement in Practice if () The “if block”. { ; Ideally use a block even if only one statement is ; conditionally selected. … } else The “else block”. { ; Ideally use a block even ; if only one statement is conditionally selected. … } Interactive Application Development – Winter 2025 5 Use blocks with all control statements 6 Do not use “else” unless you need it! - No empty blocks 7 Nested “if” statements if () { … if () { ; } … } else {…} Interactive Application Development – Winter 2025 8 Nested “if” statements if () {…} else { … if () { ; } … } Interactive Application Development – Winter 2025 9 Nested “if” statements if () { if () {

Use Quizgecko on...
Browser
Browser