Exercise 1
Write a C++ program to display the Hello message on the screen. (Solution)
Exercise 2
Write a C++ program that allows the entrance of two numbers and the display of their product. (Solution)
Exercise 3
Write a C++ program for swapping the content of two integers A and B entered by the user; and display these integers after swapping. (Solution)
Exercise 4
Write a C++ program that allows to display whether an integer entered on the keyboard is Odd or Even. (Solution)
Exercise 5
Write a C++ program that allows the display of the largest of three integers entered on the keyboard. (Solution)
Exercise 6
Write a C++ program program that allows the addition of comment on the mark entered on the keyboard (if the mark is greater than 10 then it displays “validated” if not “not validated” (NB: the mark is between 0 and 20!). (Solution)
Exercise 7
Write a C++ program that asks the user for two numbers M and N and then informs him if the product of these two numbers is positive or negative. The case where the product can be null is included in the program. (Solution)
Exercise 8
Write a C++ program that calculates the absolute value of an integer entered by the user. (Solution)
Exercise 9
Write a C++ that calculates the sum of three integers entered by the user. (Solution)
Exercise 10
A store offers to its customers 15% off on the purchase amounts over 200 DH. Write a C++ program that allows to enter the total price excluding VAT and to calculate the amount including VAT taking into account the discount and that VAT = 20%. (Solution)
Exercise 11
Write a C++ program that asks for the age of a child and allows you to inform about its category knowing that the categories are as follows: - "Kid from 6 to 7 years old" - "pupil from 8 to 9 years old" - "kid of 10 to 11 years old "-" cadet after 12 years ". (Solution)
Exercise 12
Write a C++ program to display months in letters according to the number entered on the keyboard. (If the user types 1 the program displays January, if 2 displays February, if 3 displays March...) (Solution)
Write a C++ program to display months in letters according to the number entered on the keyboard. (If the user types 1 the program displays January, if 2 displays February, if 3 displays March...) (Solution)
Exercise 13
Write a C++ program that displays "Good evening" 10 times. Using the While loop. (Solution)
Write a C++ program that displays "Good evening" 10 times. Using the While loop. (Solution)
Exercise 14
Write a C++ program that calculates the sum S = 1 + 2 + 3 + ... + 10. Using the While loop. (Solution)
Write a C++ program that calculates the sum S = 1 + 2 + 3 + ... + 10. Using the While loop. (Solution)
Exercise 15
Write a C++ program that calculates the sum S = 1 + 2 + 3 + ... + N, where N is entered by the user. Using the While loop. (Solution)
Write a C++ program that calculates the sum S = 1 + 2 + 3 + ... + N, where N is entered by the user. Using the While loop. (Solution)
Exercise 16
Write a C++ program that displays "hello" 10 times. Using the For-loop. (Solution)
Exercise 17
Write a C++ program that calculates the sum S = 1 + 2 + 3 + ... + 10. Using the For-loop. (Solution)
Write a C++ program that calculates the sum S = 1 + 2 + 3 + ... + 10. Using the For-loop. (Solution)
Exercise 18
Write a C++ program that calculates S = 1 + 2 + 3 + 4 +…. + N. where N is entered on the keyboard by the user. Using the For-loop. (Solution)
Write a C++ program that calculates S = 1 + 2 + 3 + 4 +…. + N. where N is entered on the keyboard by the user. Using the For-loop. (Solution)
Exercise 19
Write a C++ program that displays the multiplication table of 5. Using the For-loop. (Solution)
Write a C++ program that displays the multiplication table of 5. Using the For-loop. (Solution)
Exercise 20
Write a C++ program that displays the multiplication table of an integer entered by the user, Using the For-loop. (Solution)
Write a C++ program that displays the multiplication table of an integer entered by the user, Using the For-loop. (Solution)
Exercise 21
Write a C++ program that displays "Hello" 10 times. Using the do-while Loop. (Solution)
Write a C++ program that displays "Hello" 10 times. Using the do-while Loop. (Solution)
Exercise 22
Write a C++ program that calculates the sum S = 1 + 2 + 3 + ... + 10. Using the do-while Loop. (Solution)
Write a C++ program that calculates the sum S = 1 + 2 + 3 + ... + 10. Using the do-while Loop. (Solution)
Exercise 23
Write a C++ program that displays the multiplication table of 8. Using the do-while Loop. (Solution)
Write a C++ program that displays the multiplication table of 8. Using the do-while Loop. (Solution)
Exercise 24
Write a C++ program to enter 10 integers and store them in a table called Table, then display them. (Solution)
Write a C++ program to enter 10 integers and store them in a table called Table, then display them. (Solution)
Exercise 25
Write a C++ program for entering 10 numbers and displaying the average of these scores. (Solution)
Write a C++ program for entering 10 numbers and displaying the average of these scores. (Solution)
Exercise 26
Write a C++ program allowing the entrance of 10 integers and the display the maximum of these integers. (Solution)
Write a C++ program allowing the entrance of 10 integers and the display the maximum of these integers. (Solution)
Exercise 27
Write a C++ program that allows to enter 10 integers in a table, and to calculate the number of occurrences of an element N in this table. Where N is entered by the user. (Solution)
Write a C++ program that allows to enter 10 integers in a table, and to calculate the number of occurrences of an element N in this table. Where N is entered by the user. (Solution)
Exercise 28
Write a C++ program to enter 10 integers in a array and sorting this array in an ascending order. Then display this array after sorting. (Solution)
Write a C++ program to enter 10 integers in a array and sorting this array in an ascending order. Then display this array after sorting. (Solution)
Exercise 29
Write a C++ program to calculate the factorial of an integer entered by the user. For example N = 7 the factorial of 7 equal to 1* 2 * 3 * 4 * 5 * 6 * 7 = 5040. (Solution)
Write a C++ program to calculate the factorial of an integer entered by the user. For example N = 7 the factorial of 7 equal to 1* 2 * 3 * 4 * 5 * 6 * 7 = 5040. (Solution)
Exercise 30
Write a C++ program to display Even numbers between 0 and N, where N is entered by the user. (Solution)
Write a C++ program to display Even numbers between 0 and N, where N is entered by the user. (Solution)
Exercise 31
Write a C++ program that calculates the sum of Odd integers from 1 to an integer N entered by the user. Example N=8 Sum = 1 +3+5+7= 16 (Solution)
Write a C++ program that calculates the sum of Odd integers from 1 to an integer N entered by the user. Example N=8 Sum = 1 +3+5+7= 16 (Solution)
Exercise 32
Write a C++ program that allows the calculation of the greatest common divisor (GCD) between two integers entered by the user. For example: M= 15 et N=10 GCD (15 , 10) = 5 (Solution)
Write a C++ program that allows the calculation of the greatest common divisor (GCD) between two integers entered by the user. For example: M= 15 et N=10 GCD (15 , 10) = 5 (Solution)
Exercise 33
Write a C++ program that displays a triangle of integers, according to an integer entered by the user. Example N=4
1
22
333
4444
Write a C++ program that displays a triangle of integers, according to an integer entered by the user. Example N=4
1
22
333
4444
Exercise 34
Write a C++ program that calculates the number of digits of an integer N entered by the user Exemple N = 10843
the number of digits is : 5 (Solution)
Write a C++ program that calculates the number of digits of an integer N entered by the user Exemple N = 10843
the number of digits is : 5 (Solution)
Exercise 35
Write a C++ program that allows you to reverse the digits of an integer N entered by the user. for example N = 35672 the result is 27653 (Solution)
Write a C++ program that allows you to reverse the digits of an integer N entered by the user. for example N = 35672 the result is 27653 (Solution)
Exercise 36
Write a C++ program that allows you to enter an integer N and display the triangle of stars. for example N = 4
*
***
*****
*******
Write a C++ program that allows you to enter an integer N and display the triangle of stars. for example N = 4
*
***
*****
*******
Exercise 37
Write a C++ program that allows the entrance of 10 integers in a table. Then count how many Odd and Even elements are there. (Solution)
Write a C++ program that allows the entrance of 10 integers in a table. Then count how many Odd and Even elements are there. (Solution)
Exercise 38
Write a C++ program that displays if an integer N entered on the keyboard is Prime or not. (Solution)
Write a C++ program that displays if an integer N entered on the keyboard is Prime or not. (Solution)
Exercise 39
Write a C++ program that requires entering a table T of 10 integers, and putting the even elements in a T1 table and the Odd elements in a T2 table. Then display T1 and T2 (Solution)
Write a C++ program that requires entering a table T of 10 integers, and putting the even elements in a T1 table and the Odd elements in a T2 table. Then display T1 and T2 (Solution)
Exercise 40
Write a C++ program which allows the user to enter a series of integers ending in 0, and which displays at the end the number of occurrences of 5 (Solution)
Exercise 41
Write a C++ program that allows to enter 10 integers and say if these integers are consecutive or not. (Solution)
Exercise 42
Write a C++ program which allows the entrance of 10 integers and which calculates the difference between the sum of the even elements and the sum of the Odd elements.
for example : 1 6 7 4 5 3 1 8 2 5
==> (6+4+8+2) - (1+7+5+3+5+1) = -2 (Solution)
Write a C++ program which allows the entrance of 10 integers and which calculates the difference between the sum of the even elements and the sum of the Odd elements.
for example : 1 6 7 4 5 3 1 8 2 5
==> (6+4+8+2) - (1+7+5+3+5+1) = -2 (Solution)
Exercise 43
Write a C++ program allowing, from a real X and a positive integer value N, to calculate X power N (Solution)
Exercise 44
Write a C++ program that allows to test the equality between two tables of integers (sizes 10). The program displays TRUE if the components of the two tables match position by position, otherwise it displays FALSE. (Solution)
Exercise 45
Write a C++ program that counts the number of duplicate elements (two or more elements) in a table of integers entered by the user. (Solution)
Write a C++ program that counts the number of duplicate elements (two or more elements) in a table of integers entered by the user. (Solution)