0% found this document useful (0 votes)
25 views1 page

Activity 4.2

The document contains two test questions with arithmetic statements and boolean expressions to evaluate. For Test A, the summary provides the values of the integer and float variables and evaluates each arithmetic statement to its value. For Test B, the summary evaluates each boolean expression writing "True" or "False" based on the values of integer variables x, y, and z.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

Activity 4.2

The document contains two test questions with arithmetic statements and boolean expressions to evaluate. For Test A, the summary provides the values of the integer and float variables and evaluates each arithmetic statement to its value. For Test B, the summary evaluates each boolean expression writing "True" or "False" based on the values of integer variables x, y, and z.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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