Algorithm Exercises
Algorithm Exercises
10. Write an algorithm to read three integer values and display them on the screen.
the largest and the smallest of them. Consider that all the values are different.
13. Write an algorithm that reads three values for the sides of a triangle.
The algorithm must check if the triangle is equilateral (all sides equal),
isosceles (two equal sides) or scalene (all sides different).
14. Write an algorithm that reads integer values into two variables.
different.
If the rest of theif the division of the first by the second is 1, show the sum of these.
variables plus the remainder of the division;
If it is 2, write whether the first and second values are even or odd;
If it is equal to 3, multiply the sum of the read values by the first one.
If it is equal to 4divide the sum of the read numbers by the second, if this is
different from zero.
In any other situation, show the square of the numbers read.
15. Write an algorithm to read two values and one of the following
operations to be performed (coded as follows: 1– Addition, 2–
Subtraction, 3– Multiplication and 4–Division). Calculate and write the result of this
operation on the two read values.
18. Create an algorithm that receives a person's salary amount and the amount
of the intended financing. If the financing is less than or equal to 5
the salary of the person, the algorithm should write 'Financing'
Granted; otherwise, he must write 'Funding Denied'. Independent
whether to grant the financing or not, the algorithm will later write the sentence.
Thank you for consulting us.
19. The Environment Secretary, which controls the pollution index, maintains
3 groups of industries that are highly polluting to the environment. The index
the acceptable pollution varies from 0 (zero) to 0.25. If the index rises to 0.3 the
industries of the 1st group are summoned to suspend their activities, if the index
to grow to 0.4, the industries of the 1st and 2nd group are urged to suspend.
their activities, if the index reaches 0.5 all groups must be notified to
paralyze their activities. Create an algorithm that reads the pollution index
issue the appropriate notification to the different groups of companies.
21. Develop an algorithm that informs whether a given year is a leap year or not. Note:
A year is a leap year if it is divisible by 400 or if it is divisible by 4 and not
by 100.
22. Create an algorithm that determines the largest among N numbers. The condition
The stop is to input a value 0, that is, the algorithm should process the largest.
until the input is equal to 0 (ZERO).
23. Create an algorithm that counts from 1 to 100 and emits at each multiple of 10.
Multiple of 10.
24. Develop an algorithm that generates and writes the odd numbers between
numbers between 100 and 200.
28. The conversion from degrees Fahrenheit to degrees Celsius is obtained by: C ←
(F-32)*5/9. Create an algorithm that calculates and writes a table in Celsius
in function of Fahrenheit degrees, which range from 50 to 150 in increments of 2.
34. A certain company conducted a survey to find out if people liked it.
or not of a new product launched in the market. For this, the gender was provided.
of the interviewee and their response (yes or no). Knowing that there were
interviewed 2,000 people, create an algorithm that calculates and writes:
The number of people who answered yes;
The number of people thatThey answered no;
The percentage of female respondents who answered yes;
The percentage of male respondents who answered no;