How many bytes are used for a variable of type char in C?
Is the address 0x00009661 aligned to store a 8-byte integer?
Consider the following content of a portion of memory (in the form of address: value):
0x1000: 0xbe 0x1001: 0xe2 0x1002: 0x0f 0x1003: 0x61 0x1004: 0x42 0x1005: 0x49 0x1006: 0x84 0x1007: 0xf4
What is the big-endian value of the 4-byte integer in hexadecimal at address 0x1004?
0x424984f4
Consider a C program running on a big endian processor with the following variable declaration.
int a = 28;
Assume that the memory address of the variable a is 0x2000.
Indicate which of the following statements are true immediately following the execution of this statement.
Note that in some questions the format address: value shows the value of individual bytes.
char value at address 0x2003 is equal to the numerical value of 0x00000000char value at address 0x2003 is equal to the numerical value of 0x0000001cchar value at address 0x2000 is equal to the numerical value of 0x0000001c0x2000: 0x00 0x2001: 0x00 0x2002: 0x00 0x2003: 0x1c
int value at address 0x2000 is 0x0000001c0x2000: 0x00 0x2001: 0x00 0x2002: 0x00 0x2003: 0xc1
Select all possible options that apply.
Consider the following content of a portion of memory (in the form of address: value)
0x1000: 0x7f 0x1001: 0x38 0x1002: 0x39 0x1003: 0x3a 0x1004: 0x4f 0x1005: 0x2b 0x1006: 0x53 0x1007: 0x6e
What is the big endian value of the 4-byte integer at address 0x1004?
Consider a memory unit that is shared between two CPUs: one uses big endian, and the other uses little endian. Assume that the big-endian CPU stores, at address 0x8e497b10, a 4-byte integer with the value 374890817 (or 0x16586141 in hex).
After the operation completes, the little-endian CPU reads a 4-byte integer from address 0x8e497b10. What is the value of the integer read by the little-endian CPU? You may provide your answer in base 10 or in base 16, but if using base 16 you must include the prefix 0x.
0x41615816
Assuming that i is an integer variable that stores a non-negative value, which of the following computes the same value as i % 8 (i.e., i by 8).
i << 8i & 8i & 7i << 3i >> 8i & 3i >> 3Assuming i is an integer variable whose value is non-negative and evenly divisible by 4. Which of the following computes the same value as i / 4 for all possible values of i?
i >> 2i & 2i << 2i & 4i << 4i >> 4i & 3Consider a computer system that uses big-endian integer representation. Assume that the CPU stores, at address 0x8ab25f28, the 4-byte integer value 0x774f471d.
After the operation completes, the CPU reads, from address 0x8ab25f28, a 2-byte integer. What is the value of the integer read by this operation? Provide your answer in base 16. If the information above is not enough to determine the result, keep the answer blank.
0x774f
What is the value of i in hexadecimal after the following C statements execute?
char b = 0x70;
int i = 0xff & (b << 4);
0x00
What does the following Java program print?
void foo() {
int a = 0x1266b101;
a = ((0xf & a) << 28) | (a >>> 4);
System.out.printf("0x%x\n", a);
}
0x11266b10
Consider the following declaration and initialization of C global variables.
char c;
int i;
i = (char) 0xd9;
What is the value of this variable?
i=0xffffffd9
i = (unsigned char) 0xea;
What is the value of this variable?
i=0xea
i = 0xce2b708a & 0x90000099;
What is the value of this variable?
i=0x80000088
i = (int)0xc4ebadb6 >> 2;
What is the value of this variable?
i=0xf13aeb6d
c = 0x87;
i = (c & (int) 0x90000036) >> 2;
What is the value of this variable?
i=0xe4000001