Algorithm Design and Program Logic Exercises
Classified in Electronics
Written on in
English with a size of 2.72 KB
FIRST INTRODUCTION TO PROGRAM EVALUATION
I. - determines the outcome of the following algorithms.
Exercise A: Observe the following sequence of instructions:
1.Leer (A)
2.I (B)
3.I (C)
4.D = (A == B)
5.E = (A <> B)
6.F = (MOD (B / A)> = C)
Now answer the following questions: Suppose the user enters 3 in A, 4 B and 5 C
a) What value contains D after the fourth instruction?
b) What value contains E after the fifth instruction?
c) What value contains F after the sixth instruction?
d) What are A, B and C after the last statement?
Exercise B: Observe the following sequence of instructions:
1.Leer (A)
2.Result = 1
3.Mientras (A> 1)
4.Resultado = result * A
5.A = A - 1
6.Fin while
7.Imprimir (result)
Now answer the following questions:
a) If the first instruction inserts a value of 2 in A What value is printed?
b) If the first instruction inserts a value 3 in A What value is printed?
c) If the first instruction inserts a value of 4 in A What value is printed?
d) What is being calculated?
II .- DEVELOP following algorithms.
A. - We know the statistics of a subject, therefore, need an algorithm that reads the status of students until the user presses -1. With each rating must account for: all those suspended, number of approved, not remarkable and outstanding. A score less than or equal to 6 is suspended more than 6 is approved, greater than 8.5 is significant and 10 are outstanding. At the end should print: total students, total suspended, adopted, as well as notable and outstanding
a. The percentage of students who have completed the course.
b. The percentage of Fail, Pass, Merit and Distinction of the subject.
B. - The following is a restaurant menu of sandwiches. Design an algorithm capable of reading the number of units consumed each meal ordered and calculate the total customer account, the program should end when the user presses the question another account na s / n. The program should also count how many units were sold to the final meal and the total sale of the day. It must further take it that if you buy more than 10 units of each food are subject to a discount of 5% to its total sales, and if more than 20 sera from 10% to its total sales.
· Ham sandwich (10)
· Cheese sandwich (10)
· Chips (25)
· Sodas (12)
· Beer (15)