# Chapter 2: Pseudocode and Flowcharts

## 2.4 Practice Problems of Chapter 2: Pseudocode and Flowcharts

To truly get a grasp of writing pseudocode and understanding flowcharts, it's essential to engage in practical exercises. Here are a few practice problems to help you solidify your understanding:

**Problem 1**

You are tasked to design an algorithm that prints out all the numbers from 1 to 100 that are divisible by 7.

Pseudocode solution:

`Algorithm: Print Numbers Divisible by 7`

Input: None

Output: Numbers from 1 to 100 that are divisible by 7

1. For each number N from 1 to 100, do

2. If N is divisible by 7 then

3. Print N

4. End If

5. End For

**Problem 2**

Design an algorithm that checks whether a given word is a palindrome or not. A palindrome is a word that reads the same backward as forward, e.g., "level".

Pseudocode solution:

`Algorithm: Check Palindrome`

Input: A word - Word

Output: Whether the word is a palindrome

1. Initialize Start to 0

2. Initialize End to the length of Word - 1

3. While Start is less than End, do

4. If the character at position Start in Word is not equal to the character at position End in Word then

5. Return "Not a palindrome"

6. End If

7. Increment Start by 1

8. Decrement End by 1

9. End While

10. Return "Palindrome"

**Problem 3**

Design an algorithm that, given a list of numbers, finds the highest number in the list.

Pseudocode solution:

`Algorithm: Find Highest Number`

Input: A list of numbers - Numbers

Output: The highest number in the list

1. Initialize Highest to the first number in Numbers

2. For each Number in Numbers, do

3. If Number is greater than Highest then

4. Set Highest to Number

5. End If

6. End For

7. Return Highest

We recommend trying to draw flowcharts for these algorithms as well. This practice will solidify your understanding of how algorithms are represented graphically and will make you more comfortable with both forms of algorithm representation.

Remember, practice is the key to learning. By working through these problems and creating your own, you'll enhance your ability to translate real-world problems into algorithms.

## 2.4 Practice Problems of Chapter 2: Pseudocode and Flowcharts

To truly get a grasp of writing pseudocode and understanding flowcharts, it's essential to engage in practical exercises. Here are a few practice problems to help you solidify your understanding:

**Problem 1**

You are tasked to design an algorithm that prints out all the numbers from 1 to 100 that are divisible by 7.

Pseudocode solution:

`Algorithm: Print Numbers Divisible by 7`

Input: None

Output: Numbers from 1 to 100 that are divisible by 7

1. For each number N from 1 to 100, do

2. If N is divisible by 7 then

3. Print N

4. End If

5. End For

**Problem 2**

Design an algorithm that checks whether a given word is a palindrome or not. A palindrome is a word that reads the same backward as forward, e.g., "level".

Pseudocode solution:

`Algorithm: Check Palindrome`

Input: A word - Word

Output: Whether the word is a palindrome

1. Initialize Start to 0

2. Initialize End to the length of Word - 1

3. While Start is less than End, do

4. If the character at position Start in Word is not equal to the character at position End in Word then

5. Return "Not a palindrome"

6. End If

7. Increment Start by 1

8. Decrement End by 1

9. End While

10. Return "Palindrome"

**Problem 3**

Design an algorithm that, given a list of numbers, finds the highest number in the list.

Pseudocode solution:

`Algorithm: Find Highest Number`

Input: A list of numbers - Numbers

Output: The highest number in the list

1. Initialize Highest to the first number in Numbers

2. For each Number in Numbers, do

3. If Number is greater than Highest then

4. Set Highest to Number

5. End If

6. End For

7. Return Highest

We recommend trying to draw flowcharts for these algorithms as well. This practice will solidify your understanding of how algorithms are represented graphically and will make you more comfortable with both forms of algorithm representation.

Remember, practice is the key to learning. By working through these problems and creating your own, you'll enhance your ability to translate real-world problems into algorithms.

## 2.4 Practice Problems of Chapter 2: Pseudocode and Flowcharts

To truly get a grasp of writing pseudocode and understanding flowcharts, it's essential to engage in practical exercises. Here are a few practice problems to help you solidify your understanding:

**Problem 1**

You are tasked to design an algorithm that prints out all the numbers from 1 to 100 that are divisible by 7.

Pseudocode solution:

`Algorithm: Print Numbers Divisible by 7`

Input: None

Output: Numbers from 1 to 100 that are divisible by 7

1. For each number N from 1 to 100, do

2. If N is divisible by 7 then

3. Print N

4. End If

5. End For

**Problem 2**

Design an algorithm that checks whether a given word is a palindrome or not. A palindrome is a word that reads the same backward as forward, e.g., "level".

Pseudocode solution:

`Algorithm: Check Palindrome`

Input: A word - Word

Output: Whether the word is a palindrome

1. Initialize Start to 0

2. Initialize End to the length of Word - 1

3. While Start is less than End, do

4. If the character at position Start in Word is not equal to the character at position End in Word then

5. Return "Not a palindrome"

6. End If

7. Increment Start by 1

8. Decrement End by 1

9. End While

10. Return "Palindrome"

**Problem 3**

Design an algorithm that, given a list of numbers, finds the highest number in the list.

Pseudocode solution:

`Algorithm: Find Highest Number`

Input: A list of numbers - Numbers

Output: The highest number in the list

1. Initialize Highest to the first number in Numbers

2. For each Number in Numbers, do

3. If Number is greater than Highest then

4. Set Highest to Number

5. End If

6. End For

7. Return Highest

We recommend trying to draw flowcharts for these algorithms as well. This practice will solidify your understanding of how algorithms are represented graphically and will make you more comfortable with both forms of algorithm representation.

Remember, practice is the key to learning. By working through these problems and creating your own, you'll enhance your ability to translate real-world problems into algorithms.

## 2.4 Practice Problems of Chapter 2: Pseudocode and Flowcharts

**Problem 1**

Pseudocode solution:

`Algorithm: Print Numbers Divisible by 7`

Input: None

Output: Numbers from 1 to 100 that are divisible by 7

1. For each number N from 1 to 100, do

2. If N is divisible by 7 then

3. Print N

4. End If

5. End For

**Problem 2**

Pseudocode solution:

`Algorithm: Check Palindrome`

Input: A word - Word

Output: Whether the word is a palindrome

1. Initialize Start to 0

2. Initialize End to the length of Word - 1

3. While Start is less than End, do

4. If the character at position Start in Word is not equal to the character at position End in Word then

5. Return "Not a palindrome"

6. End If

7. Increment Start by 1

8. Decrement End by 1

9. End While

10. Return "Palindrome"

**Problem 3**

Design an algorithm that, given a list of numbers, finds the highest number in the list.

Pseudocode solution:

`Algorithm: Find Highest Number`

Input: A list of numbers - Numbers

Output: The highest number in the list

1. Initialize Highest to the first number in Numbers

2. For each Number in Numbers, do

3. If Number is greater than Highest then

4. Set Highest to Number

5. End If

6. End For

7. Return Highest