The following code statements appear in sequential order in

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?

Solution

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

 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 addres

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site