161k views
4 votes
It is legal to have a function with no arguments. TRUE FALSE

User Cato Cato
by
7.0k points

1 Answer

2 votes

Answer:

TRUE

Step-by-step explanation:

A parameter is a variable in a method definition and an argument is the value to this variable that gets passed to the function.

public void CalculateAdd(int i, int j)

{

Console.WriteLine(i+j);

}

In the above defined function, i and j are parameters .

We pass arguments when the function is called.

CalculateAdd(10,20);

10 and 20 are arguments which are passed to the above function to calculate addition operation.

If a function has no parameters, then it is legal to have no arguments.

For example,

public void PrintMessage()

{

Console.WriteLine("Hello");

}

The above function has no parameters. So, you can call the function without passing any arguments to it as shown below.

PrintMessage();

User Wolter
by
8.5k points