#define FOO(a, b) ((a x a) + (b x b))
...
printf("%d", FOO(1, 2+3);
What is printed out?
a. 22
b. 24
c. 26
d. 12 correct answers d
What is the output of the following code snippet?
...
int arr[] = {1, 2, 3, 4};
int i, sum;
for (i = 0, sum = 0; i < 4, i++){
sum += arr;
arr++;
}
...
a. compilation error
b. segmentation error
c. 10
d. 6 correct answers b
If the function foo has the following signature:
void foo(int a, int b, int c, int d);
how is b passed to foo?
a. In rdi
b. In rsi
c. In rbx
d. On the stack correct answers b
in Intel x86, stack pointer:
a. stores the flag registers
b. points the top of the program stack
c. stores the stack variables
d. servers as an accumulator correct answers b
In 32 bit IEEE 754 floating point standard, how many bits are reserved for exponent and
precision?
a. 9 and 22
b. 8 and 23
c. 8 and 24
d. 7 and 24 correct answers b
, In 32 bit IEEE 754 floating point standard, which of the following bit patterns represents
+infinity?
a. 01111111100000000000000000000000
b. 01111111111100000000000000000000
c. 01111111111111111111111111111111
d. None of the other choices correct answers a
In 32 bit IEEE 754 floating point standard, which of the following bit patterns does not represent
NaN?
a. 11111111100000000000000000000000
b. 01111111100000000000000000000000
c. 01111111111111111111111111111111
d. Both a and b correct answers a because it is -infinity
Pick the most appropriate statement regarding structures in C.
a. Size of a structure in memory is exactly equal to the sum of its members
b. If a structure has 2 members, address of the 2nd member is always greater than the address of
the 1st member
c. The compiler may split a structure into multiple parts and allocate them on different pages to
optimize memory utility.
d. All structure must be typedefined using typedef correct answers b
In Intel x86:
a. Function arguments are pushed on the stack left to right
b. Function arguments are pushed on the stack right to left.
c. the order in which arguments are populated does not matter
d. Except variable argument functions like printf, arguments are pushed from left to right for all
other functions correct answers b
In the following code (assume syntactic correctness and no protections in place), buffer overflow
WILL NOT occur if:
int main(){
char s[A], d[B];
...
fgets(s, 128, STDIN);
strcpy(d, s);
...
}
a. if A <= B and B == 128
b. if B <= A and A == 128
c. if A > 128 and B > 128
d. if A >= 128 and B > A correct answers d because fgets reads in 128 bits in s, so A >= 128 and
d must be larger than s, so B > A
The following code:
...