Functions and Parameters C++ - Reading Assignment


#101
  1. What is a function parameter?

    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?

    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.


#102

1. What is a function parameter?
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?
Parameters are the key mechanism by which functions can be written in a reusable way, which allows them to perform tasks without knowing the specific input values ahead of time.


#103
  1. A function parameter is a variable used in a function where the value is provided by the caller of the function.

  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.


#104
  1. A function parameter is written between the parentheses in the function, and can be used in the function.
  2. Function doesn’t need parameters but it makes the function more easier to understand.

#105
  1. What is a function parameter?
    A function parameter is a variable used in the function. It is placed between the paranthesis after the function identifier. Variable values are provided by the caller.

  2. Why do functions need parameters?
    A function needs parameters if any values are to be passed to the function. This is how we enable input to the function. The input values in this case would be called arguments.


#106
  1. A function parameter is a variable used in a function where the value is provided by the caller of the function.
  2. Functions need parameters because 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.

#107
double doubleNumber(double n)
{
    return n+n;
}

int main()
{
    cout << doubleNumber(3) << endl;
}

#108
  1. Functions are program modules wrapped around the unique parameters which behaves as variables shaping the result/return

  2. It provides reusability to the functions.


#109

Hello @ivan and dear Community,

1. What is a function parameter?

Using parameters will allow you to pass arguments whilst calling a function.

2. Why do functions need parameters?

Functions DON’T NEED parameters. :wink: Parameters affecting the behaviour of the function and it’s output.

3. Quiz code:

#include <iostream>
#include <string>

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

std::string getInput() {
    std::string x;
    std::cin >> x;
    return x;
}

int main() {
    
    std::cout << getInput() << std::endl;

    return 0;
}

Kind regards
Kevin


#110
  1. What is a function parameter?
    private variables that need to be filled with values in order to run, values are provided by the caller of the function.
  2. Why do functions need parameters?
    To be able to execute theyr procedure if those statements are coded in a way that extra data is need it to be filled before it can start.

#111
  1. What is a function parameter?
    A parameter is like a placeholder. A function parameter is variable that needs to be used by the function to perform some calculation or function. e.g. in code below “r” is the parameter which is then used to calculate the area of circle.
    double circleArea(double r) {
    return 3.141 * r * r;
    }

  2. Why do functions need parameters?
    Without parameters functions won’t be much useful e.g.
    void printHello(void) {
    cout <<“Hello world” <<endl;
    }

    will print “Hello world” to console but there isn’t any useful task being done here.


#112

Are you sure functions don’t need parameters? Without parameters functions are almost useless.


#113
  1. What is a function parameter?
    Values passed to the function that could be jused within the function.
  2. Why do functions need parameters?
    Parameter is not mandatory, but it gives information to the functions. Which can simplify code without creating global variable to use inside other functions.

#114
  1. What is a function parameter? It is a variable used in a function where the value is provided by the caller of the function.
  2. Why do functions need parameters? They are needed because they are the key mechanism by which functions can be written in a reusable way.

#115
  1. What is a function parameter?
  • Function parameters are variables that a function can use as inputs
  1. Why do functions need parameters?
  • Function parameters are used inside functions as the only way that a function can access external information