Course: CSE 220, Fall 2024
Instructors: Carl Alphonce, Ethan Blanton, Eric Mikida
Student Name: Rifa Tasfia
UBIT Name: rifatasf
Variant: k
Seat Number: Cll
Total Points: 43
Policy Agreement:
Signing indicates agreement to abide by academic integrity policies, ensuring the exam is the student’s independent work.
Write name on the front of every page.
Verify accuracy of name and UBITname on the cover sheet.
Notify an instructor or TA of errors immediately.
Answer each question to the best of your ability.
Use margins for notes or calculations.
Correct mis-marked answers by drawing a line through the wrong answer and circling the correct one.
Check all questions are answered before submission.
Question 1: The length of a C array is stored by the compiler.
Answer: False
Question 2: Every array of characters is a C string.
Answer: False
Question 3: A single line of C code corresponds to a single machine instruction.
Answer: False
Question 4: x && y and x == y are always the same if x and y are integers.
Answer: False
Question 5: The representations of numbers used by computers violate some properties of normal arithmetic.
Answer: True
Question 6: Every memory access is for an 8-byte word.
Answer: True
Question 7: Padding in a C struct is permitted only in between members.
Answer: False
Question 8: What expression has value 100 given 'a' = 97?
Answer: 'd'
Question 9: Which expressions result in "yes" being printed?
Answer: testA(4,3) && testB()
Question 10: Number of bits the processor can read/write in memory access depends on:
Answer: Size of registers on the processor and memory bus width
Question 11: Which expressions are always true, assuming a, b, c are double?
Answer: a * a >= 0 and (x + y) + z = x + (y + z)
Question 12: For the given code, which have value 53?
Answer: value, *ptr
Question 13: Relationship between arrays and pointers in C:
Answer: They are different, but closely related, with shared syntax.
Question 14: Address space relative to laptop RAM:
Answer: Address space is larger than the size of the laptop's RAM and the address space of a single process is equivalent to the RAM installed in 4,294,967,296 such laptops.
Question 15: Legal expressions in C99 for given struct example:
Answer: r = s, &r == &s
Question 16: Which have a stride of 1 on x86-64?
Answer: char, int*
Question 17: Size of the given structure:
Answer: 16 bytes
Question 18: Relationship of struct sizes:
Answer: sizeof(struct A) must be greater than sizeof(struct B)
Question 19: Which address is guaranteed to be invalid?
Answer: 0x0000000000000000
Question 20: Variable declaration for assignment legality:
Answer: char *x;
Question 21: Insertion of padding into structures ensures:
Answer: Alignment
Question 22: Memory allocation segments:
(a) string: Data
(b) f: text
(c) iSize: BSS
(d) p: stack
(e) *p: Heap
Question 23: Find out requested memory size from malloc:
Answer: You can't.