Functions and Parameters C++ - Reading Assignment

  1. What is a function parameter? A variable used in a function. Function parameters work almost identically to variables defined inside the function, but with one difference: they are always initialized with a value provided by the caller of the function.
  2. Why do functions need parameters? By using parameters, a function can take data as input
2 Likes

1.What is a function parameter?
A-Function parameter= A variable which is used in a function where the value is provided by the caller of the function.

2.Why do functions need parameters?
A- Parameters are the input for a function, so with parameters it let’s functions work with outside data passed on to them.

2 Likes

1.A function parameter is a variable which you pass into a function which the function will use in its operation.

2.They dont really need parameters per se, a function can have no parameters or a lot of parameters. Generally parameters are useful for making more complicated functions or to make customized function callls.

2 Likes

Ans 1:
A function parameter is found within the parenthesis. These are the variable values used when the function is called. The function is comprised of the keyword and declaration name, which is used to call the variable values found within the parenthesis.
Ans 2:
Although parameters are not mandatory for a functions operations, when available, they do provide variable value for the function to perform the necessary called calculus. If there are no parameters to process the main integers will execute for the parameter-less function.

1 Like
  1. A function parameter is a variable used by a function, which is provided as the argument by the caller.

  2. Functions need parameters if a value outside of the function is required for its evaluation, as a function can not access variables that were defined outside of the function.

1 Like

A function can access variables outside the function that are in the same scope. For example a global variable in a class where the function is defined.
Parameters are useful to pass in parameters that are outside of the scope of the function. Like passing in variables that are defined inside the calling function. :slight_smile:

Alright… we haven’t covered global variables and scope yet. That’s a little unfair lol

Makes total sense,thanks for the clarification. The term “class” hasn’t been discussed yet either. I think I’m discovering the limitations of learning without real-time interaction.

1. What is a function parameter? It is a variable used in a function.
2. Why do functions need parameters? It allows us to pass data into the function which the function can then process etc

1 Like
  1. Function parameters are portions of a function in which data or arguments can be entered when calling on that specific function. These arguments will be plugged into the function body to be used in a way that the function was designed. The function will then return the result of plugging these arguments into their parameters.

  2. Functions need parameters because it gives the function information that it needs to complete its processes.

1 Like
  1. A function parameter is a variable used in the function with it’s value provided by the caller of the function
  2. Function parameters are used to pass information to a function. They are not mandatory but this is a cleaner way to write code.
1 Like

1.) A function parameter is a variable used in a Function.

2.) functions need parameters to give arguments from the caller to execute the values within the function.

(Quiz)

1.) Void Multiply will have a void return.

2a.) Main() has an argument to multiply but requires 2 parameters.
2b.) Multiply() doesn’t have a return statement.

3.) Prints 24.

4.) int doubleNumber(int x)
{
return 2 * x;
}

5.) #include

int doubleNumber(int x){
return 2*x;
}

int main()
{
using namespace std;
int x = 0;
cout << "Enter a number: ";
cin >> x;
cout << doubleNumber(x) << endl;
return 0;
}

1 Like

I don’t know the quiz questions and you can check the answers after taking the quiz there are quiz results :slight_smile:

1 Like
  1. A variable used in the body of a function
  2. Depending on the purpose of the function, you may need a way to pass the value of some variable to the body of that function
1 Like
  1. What is a function parameter?
    A function parameter is a variable used in a function.
  2. Why do functions need parameters?
    In many cases, it is useful to be able to pass information to a function being called,
    so that the function has data to work with.
1 Like
  1. A function parameter passes values from one function another.
  2. Without parameters it would be very hard for functions to communicate with each other and the reusability and versatility of a single function would be severely limited.
1 Like
  1. A function parameter is a variable used in a function.

  2. Parameters allow us to pass information or instructions into functions and procedures.

1 Like
  1. A function parameter is a variable used in a function and is always initialized with a value provided by the caller of the function.

  2. Information can be passed to functions as a parameter. Parameters act as variables inside the function. Parameters are specified after the function name, inside the parentheses.

:scream_cat:

1 Like
  1. A function parameter is a variable used in the function initialized by the caller of the function.
  2. We need function parameters because so we can pass information to a function being called.
1 Like

1 -> A function parameter is a variable used in a function
2 -> because the function needs data to work with

1 Like