Monday, September 8, 2014

[LBC] Day 1 - 3: Các bài tập về Flowchart và Pseudo Code



1. Write a pseudo code and draw a flowchart to accept a value in degrees Celsius and to convert it into Fahrenheit. [Hint: C/5 = (F-32)/9]
* Pseudo code:
Begin
Input C
F = 9/5*C + 32
output F
End
* Flowchart:

2. Write a pseudo code and flowchart to accept a student’s marks in Physics, Chemistry, and Biology. The total of these marks as well as the average should be displayed.
* Pseudo code:
Begin
Input: P,C,B
TB = (T+C+B)/3
Output TB
End
* Flowchart:

3. Write flowchart to check a any number  (0-N), is it a prime?
* Pseudo Code:
Begin
Input n
i = 2
if ((n=0) or (n=1) or (n%2=0))
"n is not a prime"
else
if (n=2)
"n is a prime"
else
if (n%i=0)
"n is not a prime"
else
i = i+1
if (i>n/2)
"n is a prime"
End
* Flowchart:


No comments:

Post a Comment