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

answer is: B, and E . Please explain why the answer is what is is thoroughly. I

ID: 3827639 • Letter: A

Question

answer is: B, and E .

Please explain why the answer is what is is thoroughly. I am trying to study for my test. I will make sure to thumbs up! thank you very much for your time

7. Suppose that p is declared as follows struct s char a, b; int c int d 5); struct s *p; Which one of the following statements is illegal? b b) p 10 c) (*p) d 2 20 d) (*p) a 'a' 8. A program intended to find the maximum value in an array without changing the array is shown below. The final output is correct but it unintentionally modifies the array. Which line causes the modification? 1) include

Explanation / Answer

Dear Student,

Below i have tried to make you understand the codes..

--------------------------------------------------------------------------------------------------------------------------------------

Explanation for code:1

p->d = 10;    is the invalid statement.

Why?

in oreder to access the structure member varibles either we use dot(.) operator in normal case. If the structure varibale is a pointer then we use arrow(->) operator.

Now in your given code d is an array. And we can access a array varible either using a dot operator or arrow operator.

the correct represenation to access the varible would be.

p->d[i] = 10; (in d[i] i represent the index number as given in the option 3.)

or

(*p).d[i] = 10;

hence option 2 is invalid.

---------------------------------------------------------------------------------------------------------------------------------------

Explanation for 2nd code:

if you closely see the code then line no 14 is the main line which is used to find the maximum element in the array.

How..

Inside while loop Comparision between the value has been done. While loop run for the whole array length starting from index 0.and runs until the pNext value is less then or equal to the last element of the array that is -12.

And in if condition. when while loop runs first it compares that if *pNext > *pMax, if its true then *pMax value got updated and becomes equal to *pNext.

This happens until the loops terminated.

So updated *pMax value printed on the screen.

If you try to think logicaly then you will be able to understand the code. Now i think you may got my explnations.

---------------------------------------------------------------------------------------------------------------------------------------

Kindly Check and Verify Thanks...!!!