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

need soulotion for assignment 4 thank you Describe the scope of the declaration

ID: 3582476 • Letter: N

Question

need soulotion for assignment 4 thank you

Describe the scope of the declaration of x, y and z in the following C function: void p(int x) (int y, z; ...} Explain, what are the differences between these variables? State whether the following C function declaration are legal, and give reasons: void p(int p) {...} void p(int x) {int x; ...} void p(float p, int d) {int x; ...} By using programming language, which you prefer, write a definition of a Complex class for complex numbers. Each object of this class will represent a complex number x+y*j, storing the real part x and the imaginary part y as floats in private section. Include a constructor, a destructor access functions, assignment functions, a norm() function that returns magnitude of the complex number, an isEqualTo(Complex) function and arithmetic functions plus(Complex), minus(Complex), times(Complex), divideBy(Complex) and print() function.

Explanation / Answer

Solution for Assignment 4:

1.

The scope in any programming language is the area in which the variable remains alive or we can also say that scope of any variable defines the area in which the variable have memory in which it resides, has legal values.

The variable x,y,z all remains as legal within the function p().

The variables y,z are defined inside the body of function so they are known as local variables to function p().

The variable x is defined while declaring the function so it is known as parameterized variable of function