Question: Q 1 . ( a ) What values are printed to the screen when the following C code is executed? Explain your reasoning clearly. int

Q1.(a) What values are printed to the screen when the following C code is executed? Explain your reasoning clearly. int x =5, y =2; float z; z = x/y; printf("%.4f
", z); z =(float)y/x--; printf("%f
", z); x %= y; printf("%d
", x); (30%)(b) Describe the effect of each of the following lines of C code. Explain your reasoning. What are the values in the array a after the code has executed? int a[4]={1,5,2,7}; int *aptr; aptr = a; aptr++; aptr[0]=0; aptr = a+2; *(a+2)= aptr[1]; aptr[1]=*a+1; (35%)(c) Define a structured data type called struct complex which may be used to represent a complex number consisting of a real part and an imaginary part. Use the typedef mechanism to give your data type the new name Complex. Write a function called distance which calculates the distance between two complex numbers in the complex plane. The function should have prototype float distance(Complex z1, Complex z2); Note that the distance between two complex numbers in the complex plane is given by where and are the real part and the imaginary part of the complex number , respectively, and and are the real part and the imaginary part of the complex number , respectively.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!