The following code statements appear in sequential order in a program. float p=
ID: 3929942 • Letter: T
Question
The following code statements appear in sequential order in a program. float p= 4.0, x; int q[5] = {l, 4, 9, 16, 25}, y, z;//Assume that the base memory address of array q[] is 5000_dec x = &p; p= (x)+1; y= q; z= &q;[1];++(z); q[2]= (y+3)+3;//At this point, write down the values of the following variable expressions. Assume that an int//variable occupies 4 bytes in memory, and a float variable occupies 8 bytes II P=, x =//Y =, y =//z =, z =//q[1] =, q[2] = q= q + 2;//Is the above statement legal? If so, what is the new value of q? If not, then why not? ++y;//Is the above statement legal? If so, what is the new value of y? If not, then why not?Explanation / Answer
p=5;
*x=5
y=address of q
*y=1;
z=address of second variable of q
*z=5
q[1]=5
q[2]=19
q=q+2 is illegal. Because q is an array and scalr operatiors aren't allowed on it
Question 3:
++y is legal and is allaowed because y is a pointer variable. As it is incremented by 1, it'll now point to second variableof array
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.