CI 222 CU Flowchart Pseudo Codes and Operation Numbers Project
ANSWER
Part A: Flowchart
Here is a flowchart for finding the greatest of three different integers: a, b, and c.
Start
|
V
Input a, b, c
|
V
+---------+
| |
| a > b? |
| / \ |
| / \ |
| Yes No|
| | |
| V |
| a > c?|
| / \ |
| / \ |
| Yes No|
| | |
| V |
| a |
+---------+
|
V
Output a
|
V
End
Part B: Outcome of Pseudo Codes
a = 1
While a < 10
print in a line the value of a
a = a + 4
End while
Print "bye"
Output:
1
5
9
bye
a = 1
While a < 10
if a mod 2 is 0 then
print in a line “a is even”
else
print in a line “a is odd”
end if
a = a + 3
End while
Print “bye”
Output:
a is odd
a is even
a is odd
a is even
bye
a = 2
If a mod 2 is 0 then
While a < 10
print in a line the value of a
a = a + 1
End while
else
While a < 5
print in a line the value of a
a = a + 1
End while
End if
Print “bye”
Output:
3
4
bye
Part C: Operation Number
a = 1
While a < 6
print in a line the value of a
a = a + 1
End while
Print “bye”
Operation Number: 12
a = 1
While a < 12
print in a line the value of a
a = a + 3
End while
Print “bye”
Operation Number: 5
a = 3
While a < 7
if a mod 2 is 0 then
print in a line “a is even”
else
print in a line “a is odd”
end if
a = a + 1
End while
Operation Number: 8
a = 3
If a mod 2 is 0 then
While a < 9
print in a line the value of a
a = a + 1
End while
else
print in a line “this is else part”
End if
Print “bye”
Operation Number: 6
- Nested Loop Explanation
a = 1
While a < 3
b = 1
While b < 4
print in a line the value of b
b = b + 1
end while
a = a + 1
End While
Output Explanation: This code contains nested loops. The outer loop runs while a
is less than 3, and the inner loop runs while b
is less than 4. In each iteration of the outer loop, the inner loop prints the value of b
from 1 to 3, and then a
is incremented by 1. This pattern continues until the outer loop condition a < 3
is no longer satisfied. The output will be as follows:
1
2
3
1
2
3
bye
QUESTION
Description
Part A. Create a flowchart for the following problem.
Input: three different integers: a, b, c.
output: The greatest from the given three numbers.
For simplicity, we assume that all numbers are different.
Part B.
Find out the outcome of the following pseudo codes
1. [3 marks]
a = 1
While a < 10
print in a line the value of a
a = a + 4
End while
Print “bye”
2. [4 marks]
a = 1
While a < 10
if a mod 2 is 0 then
print in a line “a is even”
else
print in a line “a is odd”
end if
a = a + 3
End while
Print “bye”
3. [4 marks]
a = 2
If a mod 2 is 0 then
While a < 10
print in a line the value of a
a = a + 1
End while
else
While a < 5
print in a line the value of a
a = a + 1
End while
End if
Print “bye”
Part C:
1. [ 4 marks]
Compute the operation number for the following code block:
a = 1
While a < 6
print in a line the value of a
a = a + 1
End while
Print “bye”
2. [4 marks]
Compute the operation number for the following code block:
a = 1
While a < 12
print in a line the value of a
a = a + 3
End while
Print “bye”
3. [5 marks]
Compute the operation number for the following code block:
a = 3
While a < 7
if a mod 2 is 0 then
print in a line “a is even”
else
print in a line “a is odd”
end if
a = a + 1
End while
4. [5 marks]
Compute the operation number for the following code block:
a = 3
If a mod 2 is 0 then
While a < 9
print in a line the value of a
a = a + 1
End while
else
print in a line “this is else part”
End if
Print “bye”
6. [7 marks]
Explain the following nested loop with output.
a = 1
While a < 3
b = 1
While b < 4
print in a line the value of b
b = b + 1
end while
a = a + 1
End While
![Place Your Order Here](http://scholarywriters.com/wp-content/uploads/2023/08/Bottom-of-every-post.png)