# Intro to Programming: Hausa

## Section4.1Introduction to Decision Structures

 Learning Objectives: Student will be able to... understand why decision structures are important identify a situation where a decision structure would be helpful
In this chapter we will explore the concept of decision structures. We will look at what it means to include such a structure in your program, the different components that make up the structure, what the pseudo-implementation of it looks like, and how we can implement it ourselves in C++. Lastly, this chapter will conclude with examples and practice problems to help further your understanding of the body of the chapter.
Imagine you want your program to execute a piece of code but only under certain conditions. For example, Haider wants to help his sister, Maimina, with her cafe. To promote her business Maimina offers discounts to customers that spend ₦5000 or more. Haider decided to create a program that prints a discount code for customers that qualify for the discount. Customers can then use their code on future purchases.
How did Haider achieve this?
The structure Haider implemented in his code is called a decision structure. A decision structure is different from a sequence structure in that every line is not executed one after the other from top to bottom. Decision structures allow for decisions to be made on which lines of code to execute. The concept behind this flow of logic is to allow for certain segments to be run under certain conditions. Take this for instance, as Ali is walking back from school if he sees a rock in the path he walks around it. Ali walking back from school is the sequence structure as we have learned in chapter 2. He keeps walking step by step in sequential order however under the condition he sees a rock the sequence changes and he walks around it. Decision Structures can be implemented anywhere that requires a decision to be made.

### ExercisesExercises

#### 1.True or False.

Every statement in a decision structure is executed by the program
• True.

• Why do we have decision structures?
• False.

• Why do we have decision structures?

#### Exercise Group.

To complete the following activities select the correct answer to the question
##### 2.Multiple-Choice.
Which scenario is best suited for a decision structure?
• Your program takes user input that is different every time
• Your program uses the same variables and values every time it is run
• Your program takes user input but needs to execute every statement
##### 3.Multiple-Choice.
Which of the following is INCORRECT?
• Programs with decision structures can also incorporate sequential structures in them
• Decision structures allow for a decision to be made in order to determine the code to execute
• You can only have one decision structure in your program