New Jersey Institute Of Technology
CS 350 Spring 2020, CS350 Test 1, Thur, 2/20/2020
Name:
Make sure you have four pages. Do not take any page(s) with you. Any missing page(s) will result
in failure in the exam. This
...
New Jersey Institute Of Technology
CS 350 Spring 2020, CS350 Test 1, Thur, 2/20/2020
Name:
Make sure you have four pages. Do not take any page(s) with you. Any missing page(s) will result
in failure in the exam. This exam is closed book close notes. Do not exchange anything during the
exam. You all have the same exam. No questions will be answered during the exam, including
typos. I don’t want to give different answers to different people. If you are in doubt, briefly state
your assumptions below, including typos if any. Make sure you are sitting at the designated seat.
Make sure you are holding your exam, not someone else’s. You may not go to the restroom.
I have read and understood all of the instructions above. On my honor, I pledge that I have not
violated the provisions of the NJIT Academic Honor Code.
Signature: Date:
1. (6 points) Fill the table with =0, !=0, >0, >=0, <0, <=0, n/a (none of the above). Pick the closest one.
2. (4 points) When the following loop is executed: for (i=0;i<10;i++) d = fun(i); what is the earliest iteration that can start triggering "Segmentation fault (core dumped)" when compiled without stack protector?
Answer: _______________
Question Answer Question Answer
For float f=40000.0, f*f? For int i=40000, i*i?
For float f=60000.0, f*f? For int i=60000, i*i?
For float f=80000.0, f*f? For int i=80000, i*i?
typedef struct {
float x[3];
int y;
} struct_t;
double fun(int i) {
volatile struct_t s;
s.y = 314;
s.x[i] = 1.073741824;
return s.y;
}
CS350 Spring 2020 2/4 Test 1, Thur, 2/20/2020
3. (10 points) Fill in the table for bit and logical operations:
4. (8 points) Fill in with =, >, >=, <, <=, n/a for the relationship between A and B:
5. (4 points) Fill in with =, !=, >, >=, <, <=, n/a for the relationship between A and B:
6. (11 points) Consider a 6-bit two’s complement representation. Fill in the empty boxes in the following
table. Addition and subtraction should be performed based on the rules for 6-bit, two’s complement
arithmetic. TMin refers to the two’s complement minimum while TMax refers to the two’s complement maximum.
Question Answer in Hexa Question Answer in Hexa
~0x11 !0x11
[Show More]