Saad Dahlab University blida 1 1st Year / MI
Faculty of Sciences DW N°8 : The structures Algo1
Exercise 1 : (Course)
Write an algorithm in which you will :
1- Define a structure “Employee” which includes the following fields: Name, date of birth,
function, date of recruitment, salary.
2- Enter the information of n given employees (n≤100),
3- Display the names of employees with a salary ≤ 30 000 da.
4- Display the information of the employee with the highest salary.
5- Display the salary mass of employees.
Exercise 2 : (Course)
We consider the structure “Book” which contains the following informations :
Reference: integer
Title: string [50]
Author: string [30]
NB_Vol: Number of volumes for the book
Volumes: Table of 6 integers indicating the number of copies for each volume, so the first
cell indicates the number of copies of Volume 1, the second cell indicates the number of
copies of Volume 2...etc.
Write an algorithm that allows you to : Example of a book
1) Define the structure “Book” . Reference : 1005
2) Fill in a table T with the informations from 100 books. Title : The Miserables
3) Read a given R reference, then display the number of Author : Victor Hugo
copies for the corresponding book if it exists. NB_Vol : 5
Example: Reference book 1005 has 10+14+7+1+8=40 Volumes : 10 14 7 1 8
copies.
1
Saad Dahlab University blida 1 1st Year / MI
Faculty of Sciences DW N°8 : The structures Algo1
Exercise 3 : (Course)
A first-year MI student is characterized by the following informations :
Name : Student name (String ≤50).
Avg_Math : average of math modules (analysis, algebra, statistics) (real).
Avg_Comp : average of computer modules (Algo, machine structure) (real).
Avg : general average (real).
Wishes: student's choice for the course to follow in the second year (character: 'M' for a
degree in mathematics, and 'I' for a degree in computer science)
• Write an algorithm that allows you to:
1) Define the type ‘Student’.
2) Read the informations from n students (n≤400) while checking the wish values, and
the 3 averages (which must be between 0 and 20)
3) The students with a general average <10 are adjourned. Students with a general
average ≥10 are admitted to the second year and are :
- oriented according to their wishes if they have a general average ≥12,
- otherwise they will be oriented in :
* Computer science if Avg_Comp≥Avg_Math
* Mathematical if Avg_Math>Avg_Comp
* Display the names of students and their orientations following the previous rules, as well
as the percentages : adjourned students, admitted students, mathematics-oriented
students, and computer science-oriented students, according to the following format:
----------------------------------------------------------------------------
Name Decision
----------------------------------------------------------------------------
Larabi Omar Admit/Math
Maram Loubna Admit/Comp
Raber Mouloud Adjourn
…………………… ………….
----------------------------------------------------------------------------
%Adjourned : 36.5% %Admitted : 63.5% %Admit/Math : 45.2% %Admit/Comp : 54.8%
Exercise 4 : (DW)
Let the structure “contact “ be defined as follows:
- Name: string of length ≤ 50,
- Address: string of length ≤ 150,
- Telephone number: string of length ≤ 15,
- Age: integer.
Write an algorithm that allows you to:
1) Define the structure.
2) Read information of n contacts (n≤100).
3) Display all information of the youngest contact (the contact of the person with the
youngest age).
4) Show the name and age of all contacts whose names exceed 30 letters (name length >
30).
5) Display the name and address of all contacts with a phone number that starts with “021”
(for example: the number “021365502” starts with “021”).