60 Algorithm Exercises
60 Algorithm Exercises
3. From the 10 entered numbers, indicate how many are greater than zero and how many
are less than zero.
4. Design an algorithm that calculates the circumference length and the area of the
circle of given radius.
6. Create the algorithm that allows us to input a number via keyboard and
report if it is positive or negative
7. Create the algorithm that allows us to input a number via the keyboard and us
report if it is even or odd
8. Write the algorithm that allows me to read a decimal number that represents
an amount of degrees Celsius and convert that value to the equivalent amount
in degrees Fahrenheit. The program output may be as follows:
100 degrees Celsius is 212 degrees Fahrenheit
13. Create the algorithm that prints the even numbers between 1 and 100
14. Create the algorithm that prints the numbers from 1 to 100
15. Create the algorithm that prints the numbers from 100 to 0 in order.
decreasing
16. Design an algorithm that prints and sums the series of numbers
3, 6, 9, 12,..., 99.
18. Enter a number, an integer, and perform the sum of all the numbers that it
antecedents, starting from 0 and display the result on screen
19. Create the algorithm that prints all the natural numbers that are from
the unit up to a number that we enter via keyboard
20. Create the algorithm that allows us to count the multiples of 3 from the
unit up to a number that we input via keyboard
26. In a men's goods store at the end of the day, it is loaded onto the
computer the ballots that were prepared by the various sellers for
know how much the commission was for each of them for the day. The data that
The entries (by ticket) are: the seller number and the amount. When there is none
more tickets to load, enter 0. Considering that the business has 3
sellers and that the percentage on sales is 5%, indicate how much was earned.
each seller in the day
28. Given 3 numbers where the first and the last are limits of an interval,
indicate whether the third one belongs to that interval
30. Create the multiplication table of a number between 0 and 10 in such a way that it
visualize it as follows:
4x1= 4
4x2= 8
..........
31. Create an algorithm that after entering 2 numbers via keyboard, prints
the natural numbers that exist between both starting with the smallest,
count how many numbers there are and how many of them are even.
32. The employees of a company are registered with their employee number, salary and
sex (1 female and 2 male). Design in pseudocode and code in C a
algorithm that allows to inform how many women earn more than $500 and how many
men earn less than $400.
33. The amount of rainfall is entered via keyboard, in millimeters day by day.
during a month. It is requested to determine the day of the heaviest rain, the day of the least rain, and the
average
34. Create the algorithm that prints the largest and the smallest of a series of 5
numbers that we are entering via keyboard.
35. The students of a school have their last name, first name, and height recorded.
Design in Pseudocode an algorithm that indicates the name of the student most
tall and its height (only one is the tallest).
37. The meteorological log for each day records the date,
maximum temperature and minimum temperature. Design in Pseudocode a
algorithm that allows to inform: the coldest day and what that temperature was
the warmest day and what was that temperature
38. Of the 20 participants in a beauty contest, they are registering one by one.
in one of the following data:
Last Name and First Name
Points for intelligence
Points for General Knowledge
Points for Beauty
It is necessary to display on screen:
Last name and first name of the contestant with the highest overall score
Cumulative score of all participants in General Knowledge, in Intelligence
and in Beauty.
Of the three scores accumulated in the previous item, which was the lowest?
39. Write a program that calculates the weekly salary of each worker.
a company given the hourly rate and the number of hours worked as well as the
name. The user should be allowed to indicate when they wish to stop entering
data.
40. Same as the previous one but reporting at the end (the data entry and calculations.
corresponding) the number of employees for whom the salary was calculated.
41.Same as the previous one adding in the final report the name of the highest employee
salary with the corresponding salary amount and employee name
minimum salary with the corresponding salary amount
43. In a club, the following data of its members is recorded one by one:
Member number
Last name and first name
Age
Tipo de deporte que practica (1 tenis, 2 rugby, 3 voley, 4 hockey, 5 futbol)
Design in pseudocode an algorithm that allows to display on screen how many
members play tennis and how many play paddle and the average age of the players
of each sport
44.Write a program that determines if a year is a leap year. A year is a leap year
if it is a multiple of 4. Years that are multiples of 100 are not leap years, unless they
they are also multiples of 400 (2000 is a leap year but 1900 is not)
46. Design the algorithm that presents the user with a menu of options with the
four basic operations (addition, subtraction, multiplication, division). According to the
the chosen operation will take 2 integer numbers, the operation will be performed and
it will display the result on the screen. The user will be able to work in the program until
that indicates otherwise. Remember that division by zero is indeterminate.
The date of Easter corresponds to the first Sunday after the first
full moon that follows the spring equinox, and is calculated with the following
expressions:
A = year mod 19
B = year mod 4
C = year mod 7
D = (19*A + 24) mod 30
(2*B + 4*C + 6*D + 5) mod 7
N = (22 + D + E)
In which N indicates the number of the day in March (or April if N > 31) corresponding
on Easter Sunday. Create a program that calculates that date for the years
2003 and 2004.
1) Request via keyboard the result (integer data) obtained from rolling a six-sided die.
faces.
2º) Display on screen the number in letters (string data) of the opposite face of the
result obtained.
Note 2: If the number of the die entered is less than 1 or greater than 6, then
It will show the message: 'ERROR: Incorrect number.'
49. The following table shows the number of beds in the rooms
of a rural house, in addition to the floor where each one is located
they (feminine)
Note: If the number entered by the user is not associated with any
room, the message will be displayed: "ERROR: <number> is not associated with "
no room.
50. Create a program that allows the user to input, one by one, how many
characters want. That is, after entering a character the program
it will ask: another (Y/N)? and while the user chooses 'Y', allow them to continue
introducing new characters endlessly. But instead of characters
with real numbers. But instead of characters with integers. But in
instead of characters with character strings of up to 50 characters (reserving
50 positions for each chain).
54. Create a program that creates a file named salidatexto.txt and allows the
user writes all the text they want in it. They will stop entering text when
introduce an asterisk "*".
56. Create a program capable of copying a file (word for example, or any
another type) in another. The created file will be named 'copy_of' and the name of the file
to copy. The file to copy can be chosen by the user, and if it does not exist, it must have the
option to write another name until the name of a file is written that
there is.
Note: To work with files, it is interesting to configure the explorer.
Windows so that it does not hide the extensions of files for types of
known files.
This option can usually be found in Tools -> Folder Options -> View.
File extensions are used by the operating system to be able to
inform the user about the type of file in question without the need for
to know what is inside. If we create a file with the .doc extension for
for example, it will label it as a Word file, if we put .pdf it will think it's
a pdf and it will try to open it with acrobat when we double click, etc. For
in our practices we can invent an extension that is unused, due to
example .mine, this way we will recognize our files and differentiate them from
restaurant.
58. Add to the previous program the option to work with multiple agendas. To
start the program the user will be able to choose the name of the file they want to load.
The program menu will display the option to change the working file.
This option would be useful if the user has multiple companies or if they want to save them.
customer data from different sections in various databases, for
example.
59. Create a program that allows saving numbers in a list. It must have
a menu with the options, add item and print all. It must also have
the possibility of searching for and removing an element from the list.