Nested Loop Algorithm Problems Guide
Nested Loop Algorithm Problems Guide
You must calculate the average grades of all the exams in a class. There are N in the class.
students and grades (that is, you do not know in advance how many grades there are or how many)
students). You must calculate the averages for each of the students. You must say which
it was the highest grade of each student, and the highest grade of any student.
2. You must calculate the average grade of all the exams in a class. In the class, there are N
students and M grades (that is, you do not know in advance how many grades there are or how many)
students). You must calculate the averages for each of the subjects. In the end, calculate
average of all the exams.
3. Develop a program that generates the multiplication tables from 1 to 10, starting from 1
up to 20.
4. Perform this same exercise requesting up to which table you want to generate and also the
table limit (this will be requested for each of the tables). Validate that the data
provided are not negative.
5. Write an algorithm that can be used to calculate the total number of overtime hours.
worked and the total amount of money that the owner must pay in a month in a clothing store.
Overtime is paid at $15,000 on weekdays, and at $20,000 on weekends.
multiple of 6 or 7). During each working day, the number of workers present
it can be different (for example, Saturdays have more workers than Mondays). Each
The worker can also have a different number of overtime hours worked. The
the algorithm must state at the end the total number of overtime hours worked during the month, and how much
The owner had to pay the bill. You must first ask for the number of days in the month.
for which you will do the calculations and for each day the number of workers that were present,
in addition to the overtime worked by each of them.
6. Develop a program that carries out the following experiment 500 times: throw a
toss a coin 10 times and check if exactly 5 heads came up (assume heads=1, and
seal=0). They must ask what came out (heads or tails). The program must print the count.
final for the number of experiments in which exactly 5 heads appeared.
7. Realizar un algoritmo que calcule el promedio acumulado de un estudiante. Debe pedir las
notes from N semesters, and for each semester ask how many subjects he/she took and request them
notes for each of them and the credits that the subject had. In the end, they must say:
a. The number of credits taken
b. The cumulative average, and whether they are in a probation period or not, or if they are a student
distinguished.
c. How many subjects did he/she fail?
2. Create an algorithm that asks N people for a number to guess another number that
the algorithm already knows (whichever you want). You must insist to the person to give it to you
a valid number (must be greater than 0 and less than 100, that is, 2 digits). The
the algorithm can finish sooner if someone guesses the number.
3. Create an algorithm that calculates the greatest common divisor of two numbers A and B.
Recomendación: Deben probar todos los números primos que sean menores que los
Same numbers. They must start with the smallest primes (from 2 onwards)
and test if it is a divisor of both numbers. If it is a divisor of both numbers, they will take it in
count, and they will use the smallest exponent (that is, they will count how many times it divided both)
numbers, but they will take the smallest one). They must have several cycles. The cycle
the principal will try with prime numbers and will modify the values of A and B until
both numbers be equal to 1. For example:
4. Create an algorithm that calculates the least common multiple of two numbers A and B.
example: