Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume that the following C declarations are in effect: int a[4] = {6, 4, 1, 2};

ID: 3820034 • Letter: A

Question

Assume that the following C declarations are in effect:

int a[4] = {6, 4, 1, 2};

int b[8] = {9, 8, 11, 10, 5, 7, 0, 3};

int *p = &a[1];

int *q = b;

int *r = b + 2;

Give the value of each of the following expressions. If an expression is illegal, give ILLEGAL as the answer. (Consider an expression to be illegal if it is rejected by a C compiler.) If an expression is legal but has an undefined value, give UNDEFINED as the answer.

(a)   *p

(b)   *q  

(c)   *r

(d)   p + q

(e)   r - q

(f)   *(p + 1)

(g)   q[3]

(h)   b - a

Explanation / Answer

output

(a) 4

(b) 9

(c) 11

(d) invalid operand

(e) 2-1080817108

(f) 1

(g) 10

(h) 4 134519060

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote