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

int f(int *i) return (101) 1 int main) int n 5 printf (dn) return 0 Output n- Qu

ID: 3917174 • Letter: I

Question

int f(int *i) return (101) 1 int main) int n 5 printf (dn) return 0 Output n- Question 22: What will be the output of the program? include int sun (int ptt1-int ) int temp0 for lint1-01 +3 temp -pt111 return tempi int mainto int pt(51 int total. p11- 41 total - sunpt. 3) printfled and d". cotal, )return Output: total- Question 23: What will be the output of the program? inclade catdio.h int sub1(int·n) eturn int main) int m 40 nsub1 (41) printf ldm) return 0 Output m Question 24: What will be the output of the program? include int main int un, unl, un2: for (int 1-1: ie5 i+) awitch (4) case l: uni-4 break case 2: un 4 break defaulti: un uni-un2: un2 -un uniun break: printf "d", un)s return 0a Page 4/7-Exam Code PO718

Explanation / Answer

21)O/P: 40

Explanation: The f() function receives i as a pointer to a memory location.We are first setting the value stored at the memory location pointed by i to 4 (irrespective of any value stored), and then returning the product of 10 and *i, i.e., 10*4 = 40.

22) -12 and 4

Explanation: The values stored in pt[] array are {4*0, 4*1, 4*2, 4*3, 4*4} = {0, 4, 8, 12, 16}. And value of i = 4 since 5 < 5 returns false, hence it exits the forloop.

Now, since n = 3, total = total - (pt[0] + pt[1] + pt[2]) = 0 - (0 + 4 + 8) = -12

23) 55

Explanation: The function sub1() accepts a pointer to memory location as a parameter and increments the value stored in that location and returns it.

Therefore, m = 40 + (0++) + (1++) + (2++) + (3++) + (4++) = 40 + 1 + 2 + 3 + 4 + 5 = 55

24) -4

Explanation: When i=1, un1 becomes 4 and for i=2, un2 becomes 4.

Now, for i = 3 and 4, the default case runs.

For i = 3: un = un1 - un2 = 4-4 = 0, un2 = un1 = 4, un1 = un = 0.

For i = 4: un = un1 - un2 = 0-4 = -4, un2 = un1 = 0, un1 = un = -4.

Finally, un = -4