A, B, C, D, X, Y are all integers and A = 32, B = 14, C = 17; D = 8; F and G are
ID: 3822236 • Letter: A
Question
A, B, C, D, X, Y are all integers and A = 32, B = 14, C = 17; D = 8; F and G are floating point type. Y = (A/B) + (C/D)) * (A - B)) printf ("%d ", Y); b). G = (float) (D + A * B/C); printf ("2.2%f ", G); c) Int table [3] [4] = {(2, 7, 9, 4), (1, 9, 2, 3), {4, 0, 7, 6)); What would be printed for (table [2] [2]/table [2][3]________ table [2][0] * table [0] [2] _______ d) Array X initialized to (a, b, c, d, e, f, g, h). Pointer Xptr refers to the first element of X array and has a value 1246FBC. Each element is represented by 64 bit encrypted. Memory is byte organized. What are the address locations elements c, and g in the above? Specify in the hex decimal notationExplanation / Answer
a. 72
Explanation:
The expression is Y= (((A/B) + (C/D)) * (A-B))
First, by BODMAS, (A/B) is solved and it would be 32/14 = 2.28. Since both A and B are integers, the result would also be an integer, so 2.28 is converted into integer, which would be 2.
Similarly (C/D) would be (17/8) = 2.12, which woulld be converted into 2 and (A-B) would be 32-14 = 18
Now (A/B) + (C/D) would be 2+2 = 4
Finally, ((A/B) + (C/D)) * (A-B) would be 4*18= 72
b. 34.00
G= (float) (D+A*B/C)
First B/C is calculated which would be 14/17 = 0.823529
Then this result is multiplied with A, 32*0.823529= 26.352928
This result is added to D, 8+26.352928= 34.352928
Since the whole expression had only integers, the result is converted into integer, 34.
Now when we typecast 34 into float, it is converted into 34.000000
%2.2f shows only 2 values after precision, so the output is 34.00
c.
table[2][2]/table[2][3] prints 1
Reason: table[2][2] referring to 3rd row and 3rd column (array subscripts start from 0) contains 7 and table[2][3] referring to 3rd row and 4th column contains 6. 7/6 would give integer result, 1, since both are integers.
table[2][0]*table[0][2] prints 36
Reason:
table[2][0] = 4 // 3rd row, 1st column
table[0][2] = 9 // 1st row, 3rd column
4/9 = 0
d. Array elements are stored in contiguous way, i.e., all elements are stored one after other.
xPtr, pointing to first element, contains 1246FBC (hexadecimal address). Since all the elements are stored in 64-bit form, c would be stored at 1446FBC and g would be stored at 1846FBC
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.