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

The Tutorial Serie - 1

Uploaded by

ayoubmssfr97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

The Tutorial Serie - 1

Uploaded by

ayoubmssfr97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Faculty of Computer Science Speciality : Computer Science

Module ALGO1

The tutorial serie° 1


Exercice 1 :
Write an algorithm that takes two integers from the user then displays the sign of the product
without computing the multiplication and the sign of the sum without computing the addition.
Exercice 2 :
Write an algorithm allowing to write the mention obtained by a student in the baccalaureate
according to the obtained average mark.
- Mention : Very Good for candidates who obtained a score equal to or greater than 16.
- Mention : Good for candidates with an average score greater than or equal to 14 and
less than 16.
- Mention : Fairly Good for candidates with an average score greater than or equal to
12 and less than 14.
- Otherwise : no Mention.
Exercice 3 :
A class contains 200 places divided into 10 rows and 20 columns. Each student has a number
between 1 and 200. During an exam, students are placed in places according to their number
starting with the first row then the second and so on as shown in the following table:
Column 1 Column 2 --- Column 20
Row 1 Row 2 --- Row 10

1 2 --- 20

21 22 --- 40

--- --- ---

181 182 --- 200

Write an algorithm that takes an integer between 1 and 200 as input and then displays in
which row and column the student should place themselves.
For example, if n = 35, the student must place themselves in the 2nd row and the 15th
column.
Exercice 4 :
Calculate then show the sum of the first N powers of a number K such that 2 ≤ K ≤10.
Example: if the entered value of N is 5 and the number K is equal to 2 then the result is 63
(= 1+2+4+8+16+32)
Exercice 5 :
Write an algorithm to solve each of the following problems:
1- Display of the number of uppercase letters and the number of lowercase letters from a
sequence of characters ending with the character '#'.
2- Search for the minimum and maximum in a set of N real numbers.
3- comput of the quotient and remainder of the division of two integers A and B without using
the division operation.
4- Checking if a positive integer X is prime or not.
5- Display of the complete alphabet ('A' to 'Z') or ('a' to 'z').
6- Calculate the number of occurrences of a digit C (0 ≤ C < 10) in a positive integer A.

Exercice 6 :
Write an algorithm to display the Mirror of a positive integer A.
Example: Mirror of 26538 = 83562

Exercice 7 :
Write the algorithm for determining the GCD of two integers A and B using the following
methods:
Method 1: successive subtractions. Method 2: Euclidean division.

GCD (3465, 1575) GCD (7038, 5474)


A B Rest A B Rest

3465 – 1575 = 1890 7038 / 5474 1564

1890 - 1575 = 315 5474 / 1564 782

1575 – 315 = 1260 1564 / 782 0

1260 – 315 = 945


945 – 315 = 630
630 – 315 = 315 3465 / 1575 315
315 – 315 = 0 1575 / 315 0

Exercice 8 :

Write the algorithm to determine the LCM of two integers A and B (without using the GCD).

Exercice 9 :
Write an algorithm that determines and displays the Nth value of the sequence (UN), when
U = 0 ; U = 1 ; U = 2 ; U = 2U + 3U for N > 2.
0 1 2 N N-1 N-3

You might also like