0% found this document useful (0 votes)
83 views2 pages

Series 2 Algorithm

The document outlines a series of exercises for a module on the structure of computers and applications at the University Hassiba Benbouali of Chlef. It includes tasks related to algorithmic language identifiers, variable classification, algorithm execution, and the creation of algorithms for various mathematical calculations. The exercises also require the development of corresponding Python programs and flowcharts.

Uploaded by

ssouhir805
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)
83 views2 pages

Series 2 Algorithm

The document outlines a series of exercises for a module on the structure of computers and applications at the University Hassiba Benbouali of Chlef. It includes tasks related to algorithmic language identifiers, variable classification, algorithm execution, and the creation of algorithms for various mathematical calculations. The exercises also require the development of corresponding Python programs and flowcharts.

Uploaded by

ssouhir805
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/ 2

Ministry of higher education and scientific research

University Hassiba Benbouali of Chlef


Faculty of Technology
Core Science and Technology Department
Structure of computers and applications module 2024/2025
Exercise Series No. 2
Exercise 1
1) Based on the following identifiers, classify those that are valid according to the algorithmic language
and those that are not:
identifiers: AB 1 ; 2Exo ; A_Produit ; EXO2 ; Calcul% ; S.Produit ; Exercice* ; Division ; Calcul-S
2) Let the following table of variable types:
Integer Real Character String Boolean

Classify the following variables into their corresponding type from the table:
‘15.23’ ; 99 ; Faux ; 6.98 ; ‘TP informatique’ ; ‘@’ ; ‘7’ ; ‘vrai’ ; vrai ; 00 ; ‘X’ ; 33.3
3) Transform the following expressions into Algorithmic notation:
1 (𝑏+1)
2x3 ; cos(2π) ; ; (sin(x5))² ; (a-1) ; √𝑣² ; x√𝑦
𝐴𝐵 (𝑐+1)
Exercise 2
Give the values of the variables after executing each instruction:
Algorithmic Instructions
Block 1 Block 2 Block 3 Block 4
A←5 A ← -2 A ← 'S' A ← Vrai
B←3 B ← -A + 6 B ← 'T' B ← Non A
C←A+B A←A+B C←A&B C ← A et B
A ← A-1 B ← B+ 2*A D ← 'A' & 'B' D ← A ou B
C←A+B A←B–A E ← A+B B← Non (A et C)
Exercise 3
Here are the following algorithms:
Algorithme A Algorithme B Algorithme C Algorithme D
Var a, b, c, d : entier Var a, b, c, d : entier Var a, b, c : réel Var a, b, c : Chaine de
Début Début Début caractères
Ecrire (‘Donner a et b :’) Ecrire (‘Donner a et b :’) Ecrire (‘Donner a et b :’) Début
Lire (a, b) Lire (a, b) Lire (a, b) A ← ‘ENGINE’
c ← a+b c ← a*a c←a B ← ‘ERING’
d ← a*b d ← b*b a←b C←A&B
Ecrire (‘résultat= :’, c, d) Ecrire (‘résultat= :’, c, d) b←c Fin
Fin Fin Ecrire (‘résultat= :’, a, b)
Fin
a) Execute algorithms A, B and C for a=5 et b=6
b) What does each algorithm do?
Exercise 4
Write an algorithm named Surface_Rectangle that calculates the area of a rectangle with given
dimensions and displays the result in the following format: "A rectangle with a length of .... m and a
width of .... m has an area of .... m²".

1/2
Exercise 5
Write the algorithm that converts degrees to radians, such that:
The radian R of a degree D equals: R = D x π/180 radians.
- Draw the corresponding flowchart
- Write the corresponding python program

Exercise 6
Write an algorithm that asks for the coordinates of two points in the Cartesian plane, calculates, and
displays the distance between these two points.
Note: The distance AB between two points A(x1, y1) and B(x2, y2) is: AB = √((x2 - x1)² + (y2 - y1)²)
- Write the corresponding python program

Exercise 7
Write the algorithm that calculates the area of a cylinder
Note : TSA of cylinder = 2πr2 + 2πrh
with r: The radius of cylinder and h: The height of the cylinder

Exercise 8
Write an algorithm that reads the time T in seconds and displays the time T in days, hours, minutes, and
seconds.
Example: If T = 21020 seconds, the algorithm will display 0 days, 5 hours, 50 minutes, and 20 seconds.
- Draw the corresponding flowchart
- Write the corresponding python program

Conditional structure (reduced form)


Exercise 1:
Write the algorithm that displays "Positive Number" when the user inputs a strictly positive integer.
Exercice 2 :
Write an algorithm that asks the user for a number between 10 and 20, then displays an "OK" message if
the number is between 10 and 20.
- Draw the corresponding flowchart
- Write the corresponding python program
Exercise 3:
Write an algorithm that calculates the square root of a positive number.
- Draw the corresponding flowchart
- Write the corresponding python program
Exercise 4:
Write a program that checks the parity of a given integer (using the simplified reduced form).
- Draw the corresponding flowchart
- Write the corresponding python program
Exercise 5:
Write an algorithm that calculates and displays the area of a triangle, knowing that the area of a triangle =
(base * height) / 2.
Note: The base and height must be positive; otherwise, display an error message.

2/2

You might also like