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

pointers Homework 1 is a variable and p is a pointer to x, ich of following expr

ID: 3818852 • Letter: P

Question

pointers Homework 1 is a variable and p is a pointer to x, ich of following expressions are aliases for the d) &*p b) sp 2, if x is an int variable and p and q are pointers int, which of the following assignments are legal? to a) p x d) p &q; g) p b) p c) sp q 3 write a line of code for each of the examples below. Assume that numl and num2 are int variables and num1 s initialized to 5. a) Define variable p to be a pointer to an int. b) Assign the address of num1 o pointer p. c) Print the value of the variable pointed to by p. d Assign the value of the variable pointed to by p to variable num2. e) Print the value of num2. 4. Suppose that the following declarations are in effect all f 5, 15, 34, 54, 14, 2, 52, 72 h; int "p &a; [1] int q &a; a) What is the value of (p 3)? b) What is the value of (q 3) Page 321 c) What is the value Focus on Fundamentals Programming with C of

Explanation / Answer

1)Ans)

a,h

____________

2)Ans)

e,f

____________

3)

int num1=5,num2;
a)int *p;
b)p=&num1;
c)printf("%d ",*p);

d)num2=*p;
e)printf("%d ",num2);

_____________

4)

a)14
b)34
c)4
d)true (Here we are comparing the address of the memory locations)

e)false (since 15>2)

______________

5)

mismatches types
a

Non zero value
b (Here we are comparing address of the memory locations)