Professional Documents
Culture Documents
1 Tutorial Answer Fundamental of Programing (Problem Solving)
1 Tutorial Answer Fundamental of Programing (Problem Solving)
IPO:
Input Process Output
1. No 1 1. Answer is No 1 multiplication 1. Answer
2. No 2 No 2
2. Print the answer
Pseudocode:
1. Get the No 1 from user
2. Get the No 2 from user
3. Answer is multiplication od No 1 and No 2
4. Print the answer
Flowchart:
Start
Request No 1
Request No 2
Answer is No 1 x No 2
Print Answer
End
2. Determine whether a random number is greater than 50.
IPO:
Input Process Output
1. Select a random No 1. Situation of random No
2. If random No is grater than 50
Then print “YES”
Else print “NO”
Pseudocode:
1. Select a random No
2. If random No is grater than 50
Then print “YES”
3. If random No is lower than or equal to 50
Then print “NO”
Flowchart:
Start
Select a random No
NO Random YES
No > 50
End
3. Print the pass/fail grade based on the mark entered by user. The passing mark is
at least 40.
IPO:
Input Process Output
1. User mark 1. If user mark is lower than 40 1. determining the user
Then print “FAIL” situation
Else print “PASS”
Pseudocode:
1. Request the user mark
2. If user mark is lower than 40
Then print “FAIL”
3. If random No is grater than or equal to 40
Then print “PASS”
Flowchart:
Start
User mark
End
4. Print the results of the two players’ dice game
IPO:
Input Process Output
1. Player one score 1. If player one score is grater 1. result of dice game
2. Player two score than player two score Then between two players
print “player one win”
Else If player one score is
lower than player two score
Then print “player two win”
Else print “Draw”
End if
End if
Pseudocode:
1. Request Player one score
2. Request Player two score
3. If Player one score is grater than Player two score Then print “Player one is winner”
Else If Player one score is grater than or equal to 40 Then print “Player two is winner”
Else Print “Draw”
End if
End if
Flowchart:
Start C D
NO YES
A>B
D END
C
5. Print the perimeter of a rectangle
IPO:
Input Process Output
1. The measure of length 1. Perimeter is 2 x length + 2 x 1. the perimeter of a
2. The measure of width width rectangle
2. print Perimeter
Pseudocode:
1. Get the measure of length
2. Get the measure of width
3. Perimeter is 2 x length + 2 x width
4. print Perimeter
Flowchart:
Start
Request length
Request width
Perimeter is 2 x length +2 x
width
Print perimeter
End
6. Print the minimum number from 10 random numbers generated by computer
IPO:
Input Process Output
1. MIN is a new random number 1. minimum random
2. i = 0 number among 10
3. While i < 9 random number
MAX is a new random number
If MIN > MAX then MIN = MAX
i = i +1
4. Print MIN
Pseudocode:
1. MIN is a new random number
2. i = 0
3. While i < 9
4. MAX is a new random number
5. If MIN > MAX then MIN = MAX
6. i = i +1
7. Print MIN
Flowchart:
Start A
n
d
i=i+1
MIN is a new random number
N
N
NO i=8
i=0 B
B N
n YES
MAX is a new random number
d
n N
d Print MIN
End
NO
MIN = MAX
N
A
n
d
7. Print the number of odd and even number from 10 random numbers generated by
computer. The random number must be from 10 – 100.
IPO:
Input Process Output
1. i = 0 1. number of odd and
2. EVEN = 0 , ODD = 0 even numbers among
2. While i < 9 10 random number
3. RAN is a new random number
4. If RAN % 2 is 0 then EVEN = EVEN + 1
Else ODD = ODD + 1
5. i = i + 1
4. Print “even” EVEN and print “odd” ODD
Pseudocode:
1. i = 0
2. EVEN = 0
3. ODD = 0
4. While i < 9
5. RAN is a new random number
6. If RAN % 2 is 0 then EVEN = EVEN + 1
7. Else ODD = ODD + 1
8. i = i + 1
9. Print “even” EVEN
10. print “odd” ODD
Flowchart:
Start C
A
n
d
n
Print “even”
d EVEN
NO
i = 0 , EVEN = 0 , ODD = 0 RAN % 2 = 0
N
N
B YES print “odd” ODD
i=i+1 EVEN = EVEN + 1 ODD = ODD + 1 N
n N N N
d
RAN is a new random number
NO i=9 End
N
YES
A
n
d B
C