Chapitre 1-1
Chapitre 1-1
2024/2025
2
1
How to solve a problem
using algorithm ?
We’re talking about computation problems
3
Example of a problem
• Calculate the circumference C of a circle with the radius r ?
(this problem will follow us all the way to the end of the chapter)
Designing a flowchart
• A flowchart is a diagram that uses various symbols and shapes to represent a process or a series of steps, Which help
us to visualize the solution of our problem, in our case : an overview of the algorithm,
4. The Diamond (Rhombus): The decision making or the branching/ the tests
Input r
Yes No
C=2* π * r
r>0 C=0
Output C
End
7
2
Writing our first
algorithm
Before that we need to understand the different parts
of an algorithm
8
What’s algorithm ?
• Reminder :
• An algorithm is a finite sequence of elementary actions executed in a specific order
on a set of data, aiming to solve a problem.
What’s an object ?
An object is the entity manipulated by an action. Two classes of objects are distinguished:
constants and variables.
Characteristics of an Object:
An object is characterized by:
• Name: Called an identifier, it allows the object to be identified.
• Type: The set of values that an object can take (real, integer, character, etc.),
• Value: An element of the type taken at a given moment.
For example:
Name: Age Type: Integer Value: 18
• An identifier must follow certain naming rules:
• It is formed from alphabet characters (A to Z or a to z), digits (0 to 9), and the underscore character(_).
• It can be at least one character long. The first character must be a letter.
• Example:
• Correct Identifiers: TTC, Gr3, sect, Nom_Et, Note_1_2_3, X, y
• Incorrect Identifiers: 9TH, Gr 3, S?, Nom-Et
• Recommendations :
• It's preferable to choose meaningful names. And start with a lowercase character
• Some words are not allowed (see reserved keywords), And avoid long name,
13
• Every machine has memory (Central memory), generally called Random access Memory (RAM)
• This memory can receive storage instructions. So, each declaration corresponds to an instruction
that tells the memory, "Prepare a space called <ObjId>"
For example:
Const Pi = 3.141592;
Var Age: integer;
Mean: real;
Sect: character;
question: Boolean;