166k views
0 votes
Write the definition of a function square, which receives an integer parameter and returns the square of the value of the parameter. So if the parameter's value is 7, the function returns the value 49. If the parameter's value happens to be 25, the functions returns the value 625. If the value of the parameter is 0, the function returns 0.

2 Answers

4 votes

Final answer:

The function square takes an integer parameter and returns the square of the value of the parameter by multiplying it by itself.

Step-by-step explanation:

The function square is defined as a function that takes an integer parameter and returns the square of the value of the parameter. To find the square of a number, you multiply the number by itself. For example, the square of 7 is 7 x 7 = 49. The square of 25 is 25 x 25 = 625. If the parameter is 0, the function returns 0, since any number multiplied by 0 is 0. So, the square function returns the value of the parameter multiplied by itself.

User Linp
by
5.2k points
3 votes

Answer:

public static int square(int num){

return num*num;

}

Step-by-step explanation:

Using the Java Programming Language, we declare a function named square as stated in the question, the return type of the function is stated as integer. And the the parameter it receives is an integer number called num.

To get the square of the number we use the expression num*num, and return the the squared value. When the function is called, it will receive one argument (an integer value), it will calculate the square and return it.

User Techniquab
by
5.6k points