Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Test A.

Copy and answer the following:


Let a, b, c be integer variables having values 2, 4, 5 respectively and x, y, z be float variables having values 1.1,
2.5, 3.6 respectively. Determine the value of each arithmetic statements. (2pts. each)
• a+b+c
• a%b
• a/b
• a * (b / c)
• x+y+z
• x / (y + z)
• x%y
Test B. Copy and answer the following:
Determine the value of each statement by writing True or False. Let integer x = 2, y=5, z = 10
(2pts. each)
• (x<y)&&(y>=z)||(z==x)
• (y>=x) || !(z==10) && (x<z&&y==2||z>=y)
• (z%y==x)&&( (y + z)/3>=x)

Answer no 1:

a = 2 , b = 4 , c = 5, x = 1.1 , y = 2.5 , z = 3.6


a + b + c = 11
a\% b = 2
a / b = 0 // a / b = 0.5 but stores zero as are declared integer
a^ * (b/c)=0// b / c = 0
x + y + z = 7.2

x / (y + z) = 0.180328 // they are declared as float

x % y invalid as modulo operator do not work on float variables.

Answer no 2:

x = 2 y = 5 z= 10

(x < y)&&(y>=z)||(Z==x) = (true && false || false) =(true && false) = 0


(y>=x)||! (Z==10)&&(x<z&&y==2||z>=y) = (true || false && true) = (true||false) = 1
(z%y: == x)&&((y+z)/3 >= x) = (false && whatever): = false = 0 // in case of && if first condition becomes false then
second condition is not checked whole expression becomes false.

You might also like