1.
1 Self-Review Questions
1. Answer the questions below. a) What is an algorithm? Algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in which these actions are to be executed. b) What is the difference between pseudocode and flowchart? __________________________________________________________________ c) Which of the following are algorithms? i. ii. Directions on how to bake a chocolate cake. List of nutrients in a cereal box.
iii. Directions for filling out a registration form.
iv. Rules for multiplying one number by another.
2. Draw a flowchart for pseudo code below:
1. 2. 3.
4. 5.
Start Read 2 integers, A, B While A > B Repeat step 2 Print B Stop
Start
Read 2 intergers A and B
While A>B
Print B
Stop
3. The flowchart below represent a program that will calculate the time takes for a ball to hit the ground after it has been dropped from a tower. The towers height is to be read from the user. Write a pseudocode for the flowchart. (You may used C++ sqrt() library function)
START
INPUT HEIGHT, h
TIME = sqrt(2 * height / 32.2)
PRINT TIME
STOP
Presuecode: 1. 2. 3. 4. 5. Start Read Input height,H Calculate Time= sgrt(2*height/32.2) Print Time Stop