# Homework 3 Conditional Statements Answer Key

## Understanding Conditional Statements

Conditional statements are an important concept in programming. They are used to control the flow of a program. They are also used to decide which pieces of code should be executed and when. A conditional statement is a type of programming statement that is used to determine whether a certain condition is true or false. If the condition is true then a certain block of code is executed. For example, if an integer is greater than 5, then a certain piece of code will be executed.

## Types of Conditional Statements

There are three main types of conditional statements: if-else statements, switch statements, and ternary operators. An if-else statement allows the programmer to make a decision based on a certain condition. A switch statement is used to select one of several blocks of code to execute. A ternary operator is used to make a decision based on a single expression.

## Examples of Conditional Statements

Here are some examples of conditional statements. In the first example, an if-else statement is used to check if an integer is greater than 5. If it is, then the number is printed. In the second example, a switch statement is used to select the appropriate response based on the value of a variable. In the third example, a ternary operator is used to determine whether a certain condition is true or false.

## Using Conditional Statements in Homework 3

The answer key for homework 3 requires the use of conditional statements. In this homework, the student must write code that will check if a given number is divisible by 3 or 5. If it is divisible by 3, the program should print “fizz” and if it is divisible by 5, the program should print “buzz”. The student must also use a switch statement to print the appropriate message based on the number’s divisibility.

## 

Conditional statements are an important concept in programming and are a key part of homework 3. They are used to control the flow of a program and decide which pieces of code should be executed and when. There are three main types of conditional statements: if-else statements, switch statements, and ternary operators. Understanding how to use these statements is essential for completing homework 3.