Please explain how the codes ended up getting these answers, What is the math/ p
ID: 3833472 • Letter: P
Question
Please explain how the codes ended up getting these answers, What is the math/ pattern behind it? What do these codes do in each of the parts in order to get those answers?
void whatMatrix int i 0, 0; int matrixDE4) (1.2, 1, 21, 2, 1, 2, 1, 1, 2, 1, 2h, 2, 1, 2, 1) Answer is: 224 for (i 1; ic3; i++) matri 2 0) printf("%d matrix printf d ", (matrixloj[0] matrix[1][1 atrix 2002 matrix[3113 int vector H1, 2, 3, 4, 5) wherelslt(vector); for int i 0 ics; i++) print %d", vector Answer is: 1 2 3 4 5 print ("Mn"); void wherelslt(int a int b (5,4, 3, 2, 1 a b int vector20 (1, 2, 3, 4, 5) wherelslt2Ivector2 for int i 0 icS i++) print ("%d", vector2li) Answer is: 1244 S printf("Mn"); void wherelslt2(int all)I a12] a[3 void whats TheSum00 int sum 1; int i 1, j 0; while 500 0, j-- The sum is -9 printf ("%dV sum); n",Explanation / Answer
a.) since the for loop goes from 1 to 2 so the operated matrix will be like this:
1 2
2 1
since matrix[1][2] and matrix[2][1] are even no. So, therefore, it will print 22. And after the for loop, all the diagonal sum is printed which is 1+1+1+1 = 4.
So, result is 224.
b.) In the function whereIsIt, copy of the array can't done by using the assignment statement only. That's why, it prints the value of the original array 1 2 3 4 5.
c.) In the function whereIsIt, third element is changed to the 4th value of the array. So, the array now is
1 2 4 4 5
d.) for i=1, sum = 1
for i=2, sum = 1 + (2-2) + (1-2) = 0
for i=3, sum = 0 + (3-3) + (2-3) + (1-3) = -3
for i=4; sum = -3 + (4-4)+(3-4)+(2-4) + (1-4) = -9
Hope it helps, do give your valuable response.