Tutorial N°1: Simple Sequential Algorithm: Exercise 01
Tutorial N°1: Simple Sequential Algorithm: Exercise 01
Exercise 01:
Indicate whether the following words can be used as identifier or values and give its type :
Xx25ab 2y -0.5 1,8 lire & '5' "vap" 'd" 0 'M' '#'
2
alpha 25,3 14.5 -11 c/n #ff a*b faux y g! "R"
Ajou5 +9 +10.6 "k=14.9" "15" vrai Ahmed gt-at Fi
xy<5 dy cinq google.com X_1 a1 "-11,6" 'vap' vap
1TD TD1 A800 89R Prénom Prix-HT Prix_HT
Code Postal Code_Postal CodePostal
Exercise 02:
Exercise 03:
Exercise 04: Given integer variables a, b, c, d and e, evaluate the following expressions:
a = 1, b = 2, c = 3, d = 4,
a+b-c+d a+d %b - c
a * b/c+d ++a * b - c--
a * b MOD c ++b / c + a * d++
a = 8,b =15,c = 4, a = 9,b =12,c = 3,
2*((a MOD 5)*(4+(b-3)/( c+2))) a- ((b/(3+c)) *2) -1
a = 11,b = 6,c = 0,d = 7,e = 5 a=1; b=2; c=4; d=6
a+2 > b AND NOT c || a <> d AND a-2<=e a+b/c*((d/3+4)/3+a)/b ;
(a>b) OR NOT (c>=d) AND (b<c) ;
Exercise 05: The variables N, P and Q are integers and contain the values 5, 7 and 3 respectively. Are the
following expressions correct? If so, give their type and value.
– N mod P * Q
– N mod P div Q
– N = P ou N <= Q
– P div N < Q
1
Exercise 06 : Evaluate the following logical expressions with (a,b,c,d) = (2,3,5,10) and (X,Y) = (True, False)
1) (a b) (a c) 2) ((a b) (a c)) 3) (a b) (a c)
4) (a b) (c = d/2) 5) (d / a = c) = Y 6) (d / c = b) = Y
7) (d / c = b) = X 8) (a b) (d c) 9) (a b) (d c) = X
Exercise 07: Respond with “true” or “false” to each read or write operation (indicate errors):
Exercise 09 : Write two C programs that SWAP or switches the values of two integer A and B: first using an
auxiliary variable and without an auxiliary variable for the second.
Exercise 10 : Write a C program that asks for a number from the user, then calculates and displays the square of
this number.
Exercise 11 : Write a C program that inputs the price of an item (excluding tax), the number of items and the
VAT rate. The program then provides the total price including tax. (Make sure the labels appear clearly)
Exercise 12 : Write a C program that allows you to calculate the determinant of a quadratic equation:
ax2 + bx + c.
Exercise 13 : Write a C program that calculates and displays the area of a rectangle, where the width and height
will be given by the user.