Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help me solve this ploblem!! Consider the following variables where random() ret

ID: 3925325 • Letter: H

Question

Help me solve this ploblem!!

Consider the following variables where random() returns an arbitrary but valid value in the given data type (note that f and d are not cast from integer x and can have different values from x). int x = random(); float f = random(); double d = random(); For each of the following C expression, answer True/False to indicate whether the expression always yields 1 (true). If it always yields True, very briefly describe the underlying mathematical principles. Otherwise, give an example that makes it yield 0. (d + f) - d == f x * x>: = 0 f * f > = 0 x = 0

Explanation / Answer

) d = 11e+23
f =2.3
(d+f) = double answer
(d+f)-f =float answer
Therefore a = 1 (true)


2)
x * X >=0

eg : 2*2=4> 0
Therefore b = 1 (true)
eg : 2*0=0=0
Therefore b = 1 (true)

3)f*f >=0
0.1 * 0.1 = 0.01 > 0
Therefore c= 1 (true)

4)
x<0 || -x >=0
Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true.
Therefore d= 1 (true)