Part 1 - Flowchart
Part 1 - Flowchart
Part 1 - Flowchart
Lab 1
In this week, we practice drawing flowcharts to know how to design a resolution strategy in order to
solve the problem by computer. Students can see some sample exercises and must prepare solutions
for all exercises in part B.
A. Sample exercises.
Exercise 1. Design an algorithm in flowchart to read and find maximum between 2 numbers.
Solutions:
Prototype: Max(float x, float y)
Flowchart:
Solutions:
Prototype : floatconvert (float a,int sel);
//sel=1: inches to meter, sel ≠1: meter to inches
Flowchart :
Start
Input sel
sel=1?
Ye No
Input a Input a
Stop
Figure
Figure 1. Converter
SEQ Figure \* ARABICbetween meters
2. Converter andmeters
between inchesand inches
Exercise 3. Design an algorithm in flowchart to calculate the diameter, circumference, and area of
the circle of radius R.
Solutions:
Prototype : CircleDetail (float R);
Flowchart :
Start
Input R
d 2*R
p 2*3.14*R
s 3.14*R*R
Print d,p,s
Stop
Exercise 4. Design an algorithm in flowchart to find the smallest number in a group of three real
numbers. (Tìm số nhỏ nhất)
Exercise 5. Design an algorithm in flowchart to check whether a point A(x, y) is on, inside or
outside the circle with center O(x0, y0) and radius of size R. ( Kiểm tra điểm A nằm trong hay
ngoài đường tròn)
Exercise 6. Design an algorithm in flowchart to solve the quadratic equation: ax2 + bx + c =0 with
the inputs a, b, and c. (Giải pt bậc 2)
Exercise 7. Design an algorithm in flowchart to read in a group of N numbers and compute the
average of them, where N is also an input. (Tính trung bình cộng của một nhóm số N)
Exercise 9. Design an algorithm in flowchart to calculate the average of four grades of four
subjects of a student and determine whether students “Pass” (>=60) or “Fail”.
(Tính trung bình cộng của 4 môn và xác định học sinh đậu hay rớt)
C. Exercises in advanced.
Exercise 11. Design algorithm to check if a given year is leap year or not.(Leap year is divisible by
4 but not by 100 or divisible by 400.)
Hint: leap year is the year divisible by 4 but not divisible by 100, or it is divisible by 400.
Exercise 12. Design an algorithm in flowchart to read and calculate factorial of integer N.