Functions and Parameters C++ - Reading Assignment

Welcome to the discussion about the reading assignment about Functions and Parameters C++.

Leave your answers to the questions below in this thread. If you have any questions or you want to discuss something connected to the assignment feel free to do it in this thread as well, but please everything to the topic.

1. What is a function parameter?
2. Why do functions need parameters?

13 Likes
  1. values passed to the function, variables are assigned for use in the function in the order they are passed from the calling function and of the type defined in the signature.
  2. so the function has input variables to work on
  1. a variable that is used inside a function but the actual value of that variable is set within the function call
  2. they don’t NEED them. But…the possibility to use function parameters opens up a lot of new possibilities for calculation and so forth.

1. What is a function parameter?
When you call a function you can give her parameters between the parenthesis. These parameters can be used in the function.

2. Why do functions need parameters?
Parameters are not mandatory. But it allow you to give informations to the function. Then the function can modify variables, work on it…

1. What is a function parameter?
Variables that the funtion caller provides the value to

2. Why do functions need parameters?
To collect data that may be until given by the user or defined in the main function

  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. What is a function parameter?
    The parameter of a function is the type and name of the variable(s) to pass to the arguments if the function is called.

  2. Why do functions need parameters?
    Functions need parameters if their output is a variable.

1- Function parameters are values sent when function is called and are received as a variables in the function definition
2- A function need parameters to operate with, but a function may not need any parameters, usually functions without any parameters are side effects functions

1. What is a function parameter?
A function parameter is a variable used in a function whose value is passed into it by the caller.

2. Why do functions need parameters?
If we want our function to use values from our program, they must be passed onto the function as arguments. These arguments are assigned to the parameters so they can be used as variables within the scope of the function.

2 Likes

1. Variable used in a function with a value provided by the caller of the function.

2. Allows a function to perform tasks without knowing the specific input values ahead of time. Parameters are the key mechanism by which functions can be written in a reusable way.

What is a function parameter?
- The information required to be passed from one function to another.

Why do functions need parameters?
- To ensure that they can have the information they need to accurately execute.

  1. What is a function parameter? is a variable used in a function where the value is provided by the caller of the function
  2. Why do functions need parameters? When there are functions that need to interact with the user, the parameters are the only way to do it

1.A function parameter is a variable used in a function where the value is provided by the caller of the function.
2,Without proper amount of parameters the compiler will throw an error.

  1. What is a function parameter?
  2. A function parameter is a variable used in a function where the value is provided by the caller of the function.

    For example, the function bellow has two integer paramaters, x and y.

    int add(int x, int y){
       return x + y;
    }
    

    In comparison, the function is called with arguments, or values passed from the caller to the function when a function is called.

    add(2,3);
    //->5
    
  3. Why do functions need parameters?
  4. When a function is called, all of the parameters are created as variable and the value of each argument is passed into it's respective parameter. By using parameters, a function can take data as input, perform a manipulation, and return the transformed value.

1 Like
  1. function parameters are variables handed to a function.
  2. parameters are the input for a function. typically a function does some calculation on these parameters which result in a specific output (return value)

1- A function parameter is a variable used in a function where the value is provided by the caller of the function. Function parameters are placed in between the parenthesis after the function identifier, with multiple parameters being separated by commas.

2- Parameters are the key mechanism by which functions can be written in a reusable way, as it allows them to perform tasks without knowing the specific input values ahead of time. Those input values are passed in as arguments by the caller.

Quiz:
1- Multiply function is defined as void type but it returns a value and therefore it produces a compile error.
2- Multiply is defined with two input parameters but has been called with one argument that doesn’t match the parameters and makes a compile error.
3- 24
4-
int doubleNumber(int x) {
return 2 * x;
}
5-
#include

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

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

  1. A function parameter is a variable used in a function where the value is provided by the caller of the function. Function parameters are placed in between the parenthesis after the function identifier, with multiple parameters being separated by commas.
  2. To enable functions to have inputs as well.
  1. A function parameter is a variable in a function which get its initialization value at the time of execution from the caller (the concrete value is called argument).
  2. Function parameters are needed if you have to pass information to a function to influence its behaviour. However, parameters are not mandatory.

1- a fonction parameter is a variable used in a function where the value is provide by the caller of the function.

2- it is not compulsory to have parameters , but for some computation , the function need some value in order to return something …

1. What is a function parameter?
Function parameter along with return values make functions more versatile and reusable. It is a variable that gets its value from the caller. It is placed between the ‘(’ and ‘)’ after function name and has its scope just to local to function. Multiple parameters are separated by commas.

2. Why do functions need parameters?
To make function reusable. Same set of reusable statements within the function can be used for different arguments from a caller function.