171k views
0 votes
g Write a line of code to invoke a function named RandNum, which accepts no parameters, and storing the return value in a variable called num (which has already been defined). Separate each item with 1 space (except around the parentheses), and end the line with a semi-colon.

User Leo Muller
by
5.2k points

1 Answer

4 votes

Answer:

public int RandNum();

* Assuming it returns an integer

Step-by-step explanation:

I believe you mean to write the function header of randNum.

To write the header of the function, we need to specify its return type, name, parenthesis and parameters inside the parenthesis - if exist.

If it returns an integer it should have int, if it returns a double it should have double in the header. In the answer, I assumed it returns an integer.

The name is already given, RandNum

Since, the function does not take any parameter, inside of the parenthesis will be empty.

User Stephan G
by
4.4k points