0% found this document useful (0 votes)
20 views8 pages

60 Algorithm Exercises

The document contains a list of 60 algorithm exercises covering various programming concepts such as variables, loops, input/output, decisions, and data structures. Each exercise requires the design of algorithms or coding in C to solve specific problems, such as calculating averages, converting units, and managing data. The exercises aim to enhance programming skills through practical applications and problem-solving tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views8 pages

60 Algorithm Exercises

The document contains a list of 60 algorithm exercises covering various programming concepts such as variables, loops, input/output, decisions, and data structures. Each exercise requires the design of algorithms or coding in C to solve specific problems, such as calculating averages, converting units, and managing data. The exercises aim to enhance programming skills through practical applications and problem-solving tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

60 exercises of Algorithm

VARIABLES. ACCUMULATORS. COUNTERS. LOOPS AND INPUT.


DECISIONS

Enter 5 numbers and calculate their average.

2. Write the algorithm necessary to calculate and display the square of a


number. The number must be greater than zero, in case of error that appears the
ERROR, the number must be greater than zero

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.

5. Design an algorithm that calculates the area of a triangle from the


Enter its base and height and show the result.

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

9. Given certain centimeters as input of decimal type, write its


equivalent to feet (whole) and inches (decimal), giving the inches with a
precision of 1 decimal place. Consider 2.54 cm per inch and 12 inches per
The output could be: 333.3 cm is 10 feet and 11.2 inches.

10. Write in Pseudocode and code in C a program that reads 20


characters. After reading, indicate how many 'a' were entered, how many 'e, i, o,

11. Create an algorithm that allows entering a number corresponding to the


Days of a week and display the name of the day. It should allow working until
unless the user indicates otherwise.

12. Write in Pseudocode and code in C a program that displays the


números impares entre 0 y 100 y que imprima cuantos impares hay

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.

17. Write in Pseudocode and code in C a program that displays the


multiples of 2 and 3 and both between 0 and 100

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

21. Write in Pseudocode and code in C a program that displays the


prime numbers between 0 and 100

22. Design in Pseudocode and code in C an algorithm that allows inputting


10 numbers, none of them equal to zero. It is asked to sum the positives.
the product of the negatives and then show both results.

23. Design the necessary algorithm to read the value of 2


variables NUM1 and NUM2 swap the values of the variables, that is
that the value that NUM1 had now contains NUM2 and vice versa

24. Write a program that displays a table of the first N numbers.


Let N be a number entered by the user. Use the following output design.
assuming that the user entered a three:
NUMBER
1 1 1
2 4 8
3 9 27

25. Design in Pseudocode and code in C an algorithm that allows


register the employees of a factory (unknown how many) their weight and know
cuantos pesan hasta 80 kg. inclusive

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

27. Enter 3 numbers corresponding to the sides of a


triangle. Considering that the sum of the two shorter sides has to
be greater than the larger side so that they form a triangle, indicate if the numbers
the indicated points form a triangle and if they do, what type of triangle is it (according to its
sides).

28. Given 3 numbers where the first and the last are limits of an interval,
indicate whether the third one belongs to that interval

29. The hourly wage of an employee is entered via keyboard. Subsequently,


Enter the employee's name, seniority, and the number of hours worked
in the month. It is requested to calculate the amount to be charged taking into account that the total
what results from multiplying the hourly rate by the number of hours worked, there is
to add the number of years worked multiplied by $30, and to the total of
subtract 13% as discounts from all those operations. Print the
receipt corresponding with the name, the seniority, the value per hour, the total to
charge gross, the total of discounts and the net amount to be collected.

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.

MAXIMUMS AND MINIMUMS

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).

36. Design an algorithm that allows calculating a student's average.


knowing that the grades of 6 subjects and their name are entered per student. Not
know the number of students. It is requested to show: NAME OF THE STUDENT:
AVERAGE:

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

42.Same as above adding in the final report the company's cost in


salaries

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)

A mathematics teacher at an educational institution records each


student ID number, name, and average. Based on the average, wants to know
how many students passed (average greater than or equal to 7), how many take the exam in
December (average less than 7 and greater than or equal to 4) and how many take the exam in
March (average less than 4). He also wants to know the file number and name.
of the student with the highest average.

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.

48. Write a program, in C language, that:

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 1: On opposite faces of a six-sided die are the numbers: 1-6,


2-5 and 3-4.

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)

Write a program, in C language, that:

1º) Show the list of the rooms in the rural house.


2) Request the number (integer data) associated with a room via keyboard.
3º) Display on screen the floor plan and the number of beds in the room
selected.

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).

51. Create a program in C that will read 10 values from a file


numerical and then create a vector in memory dynamically. It has
to request a numerical value via console and multiply each of the elements
of the vector by that numeric value, once all processes are completed, close
the file and free the memory used by the vector.

52. Create a program that opens a file named 'prueba.txt' (previously


created with Notepad and saved in the same folder where it is
program) and display its content on screen character by character.

53. Create a program that opens a file called 'test.txt' (previously


created with notepad and saved in the same folder where it is
program) and display its content on the screen by passing to
UPPERCASE THE CHARACTERS THAT ARE IN LOWERCASE.

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 "*".

55. Create a program that opens a file named 'prueba.txt' (previously


created with Notepad and saved in the same folder where it is
program) and display its content on the screen line by line and each
line with its line number.

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.

57. Create a program to manage a client agenda for a company.


(50 characters)
(entero sin signo)”, “estado_pagos (float con signo)”. El estado de pagos será un
negative number indicating the amount of money the customer owes.
The program must present the user with a menu with the following options:
a) Add client.
b) view data of all clients.
c) Search for clients by phone. This option will ask the user for the phone number of the
desired customer and will display the other data of that customer on the screen. If
it does not find it, it will notify about it and return to the main menu.
d) Modify a client's data and save it again in the file.
e) List only the clients with debts (that is, those in which
"payment_status" is less than zero.
f) Delete a client from the agenda.
The program will work with a file (clients.mio for example) that must be created.
first time the program is run.

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.

60. Repeat the previous exercise using a binary tree.

You might also like