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

In a C code, a variable X was declared as float and an initial value was assigne

ID: 3748430 • Letter: I

Question

In a C code, a variable X was declared as float and an initial value was assigned to it. After running the code the variable X was stored in the data memory as shown in Figure 1 1. (a) 110000010000000000 1011 1 10011 1000 | X Figure 1 (i)What was the value of X in the C code? (1.5 marks) i) Write the result from question (i) as a binary fixed-point number using the minimum number of bits for the integer part and the 6 bits for the fractional parts. 1.5 marks) The value of X has changed, during the execution of the C code, to -0.0078125. (i) (b) What will be stored in the data memory in the memory location reserved for X? (1.5 marks) (i) What will be displayed on the screen by the following pc.print statement (X - -0.0078125): pc . printf ("%8.4f ", X); 0.5 marks)

Explanation / Answer

1. (a) 3238014776, just convert the binary to decimal.

(b) Your question does not seem clear. if you want to specify 6 bits for fractional part, only 6 can come after decimal as 76 has 7 bits in its bianary form. The number will be 323801477.6 in that case

b. (i) 000000, Naive converversion

(ii) I do not know what do you mean by pc.printf(), but using printf() will give -0.0078 the the format specifies how many digits should be there after decimal point. You can check it by runnig it in gcc compiler.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote