Docsity

algorithm DW first year, Summaries of Data Structures and Algorithms

Toggle sidebar
bg1
1
Dr. Yahia Fares University of Médéa
Faculty of Sciences L1 CS
Department of Mathematics and Computer Science Algorithmics and Data structures 1
Exercises sheet N°3
PW
▪ Exercise 1
Write a program to display the multiplication table of a given integer N.
E.g. N=3
3×1=3
3×2=6
3×3=9
3×4=12
3×5=15
3×6=18
3×7=21
3×8=24
3×9=27
3×10=30
▪ Exercise 2
Write a program that multiplies two natural numbers A and B by using “For” loop instead of the
multiplication operator “*”.
▪ Exercise 3
Write a program that repeatedly enters an integer value and displays its square. The process
terminates when 0 is entered.
▪ Exercise 4
Write a program which determines the first integer N such that the sum of 1 to N strictly exceeds
100
▪ Exercise 5
Given an integer, write a program that displays the sum of its digits.
E.g. 2847 2+8+4+7=21
▪ Exercise 6
Write an algorithm that finds and displays all 3-digit natural cubic numbers.
A cubic number equals the sum of its three digits cubed.
E.g 153 is cubic because 153 = 13 + 53 + 33.

Partial preview of the text

Download algorithm DW first year and more Summaries Data Structures and Algorithms in PDF only on Docsity!

1 Dr. Yahia Fares University of Médéa Faculty of Sciences L1 CS Department of Mathematics and Computer Science Algorithmics and Data structures 1

Exercises sheet N° 3

PW

▪ Exercise 1

Write a program to display the multiplication table of a given integer N. E.g. N= 3×1= 3×2= 3×3= 3×4= 3×5=

3 ×6=

3×7=

3×8=

3×9=

3 ×10=

▪ Exercise 2

Write a program that multiplies two natural numbers A and B by using “For” loop instead of the

multiplication operator “*”.

▪ Exercise 3

Write a program that repeatedly enters an integer value and displays its square. The process terminates when 0 is entered.

▪ Exercise 4

Write a program which determines the first integer N such that the sum of 1 to N strictly exceeds 100

▪ Exercise 5

Given an integer, write a program that displays the sum of its digits. E.g. 2847  2+8+4+7= 21

▪ Exercise 6

Write an algorithm that finds and displays all 3-digit natural cubic numbers. A cubic number equals the sum of its three digits cubed. E.g 153 is cubic because 153 = 1^3 + 5^3 + 3^3.