Programming-for-Output-Problems
October 6, 2023Programming-for-Output-Problems
October 6, 2023Programming-for-Output-Problems
Question 21
|
Consider the following C declaration
struct
{
short s[5];
union
{
float y;
long z;
}u;
}t;
Assume that the objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment consideration, is
struct
{
short s[5];
union
{
float y;
long z;
}u;
}t;
Assume that the objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment consideration, is
22 bytes
|
|
18 bytes
|
|
14 bytes
|
|
10 bytes
|
Question 21 Explanation:
short [5] = 5×2 = 10
max[float, long] = max [4, 8] = 8
Total = short[5] + max[float,long] = 10+8 = 18
max[float, long] = max [4, 8] = 8
Total = short[5] + max[float,long] = 10+8 = 18
Correct Answer: B
Question 21 Explanation:
short [5] = 5×2 = 10
max[float, long] = max [4, 8] = 8
Total = short[5] + max[float,long] = 10+8 = 18
max[float, long] = max [4, 8] = 8
Total = short[5] + max[float,long] = 10+8 = 18
Subscribe
Login
0 Comments