answersLogoWhite

0


Best Answer

Because of the function declaration and definition (which must match)

When you define the function:

void msgBox(int x, int y, char *message);

you have to pass it parameters in the order they were defined:

void main()

{

msgBox(5,10,"Hello World");

}

If you present the values in the wrong order, it will either not compile (type mismatch), or the function will behave unexpectedly (for instance, x and y coordinates swapped).

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How does a function know which value to attach to which parameter?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can the parameter of the copy constructor be passed by value?

No. The parameter of the copy constructor is always passed by reference, specifically, a const reference to the class.Think about it. If it were passed by value, then the compiler would already know how to copy the object into the formal parameter, but the purpose of the copy constructor is to provide the code to copy the object, so its kind of a "cart before the horse" thing to think about call by value here.


Why is parameter passing useful to programmers?

Because all software is written using functions and classes. If you do not know how to pass data from class to class, to function you are not a programmer.


How do you design a function named feetToinches that accepts a number of feet as an argument and returns the number of inches in that many feet?

You design it as an inline function with a constant unsigned reference parameter. Since there are 12 inches to the foot, the return value is the product of the parameter and 12. However, you must also ensure the return type has enough bits to store the result. C++ example: inline unsigned int feetToinches( const unsigned int & feet ){ return( feet < 357913941 ? feet * 12 : 0 ); } The above example assumes an int is 32-bits wide. If the input is larger than 357913941 (feet) then there won't be enough bits to store the result, so zero is returned instead. If the input is non-zero and the return is zero, you know the conversion failed. We use unsigned data types because you cannot have a negative unit of distance. We use a reference parameter to prevent the parameter from being copied (not strictly necessary if the type will fit within a pointer variable, but good practice nonetheless). The parameter is constant because the function does not need to modify the parameter. It is inline because the code is not complicated and is a prime candidate for inline expansion, thus eliminating the need for a function call altogether.


What is Parameter Passing and Returning values.. in Programming.. preferbly Visual Basic?

Parameters are the variables you pass to functions. Return values are the variables that are returned by those functions. Values can also be returned by the parameters themselves (such parameters are said to be output parameters).The variables you pass and return from functions will either be by value or by reference. Only references can be output parameters, since passing by value creates an automatic copy of the value which falls from scope when the function returns. Pointer variables are always passed by value. To pass a reference to a pointer you must pass a pointer to the pointer, which is itself passed by value, but refers to the pointer.Constant references are the preferred method of passing variables to functions, since there is no need to copy the variable you pass and because it is constant, the original value is left unaltered. Non-constant reference is the next best method, but only if you expect changes to be reflected back in your value (an output parameter). If you do not expect changes, then you must pass by value or, when that isn't an option, create a copy of your value and pass by non-constant reference. The only difference is that passing by value automatically destroys the copy when the function returns.Ignoring output parameters, a function can only return, at most, one value. A function that returns void has no return value, however it is good practice to always return something, even if only an integer to indicate whether the function was successful (zero) or not (non-zero). If the function is a logical function, such as Add( X, Y ), or an accessor, such as GetName() then it makes more sense to return the actual result of the function via the return value. If you need more than one return value, then you must use output parameters, passed by reference, which allows the return value to be used as an error indicator.Generally you will want to store the return value of a function, especially if the return value is a memory allocation. If you don't store the return value, the value is lost forever, unless you re-call the function with the same parameters, which is highly inefficient. However, if you only need to know the result of a function once, you don't need to store it, so long as you act upon it immediately, usually as part of a conditional expression. E.g.,int x, y; // Uninitialised, values unknown.if( x + y == 12 ) // call the int::operator+ function.// x+y is definitely 12.else// x+y is definitely not 12, but the actual sum is no longer known at this point.


Briefly explain 'h-parameter model' for BJTs?

h-parameter used to find the input and output impedence of the two port network. suppose if u connect a high load at the output port then u should take care that no current from the device will attack the network, to determine that we should know what is the impedance of the circuit.

Related questions

Can the parameter of the copy constructor be passed by value?

No. The parameter of the copy constructor is always passed by reference, specifically, a const reference to the class.Think about it. If it were passed by value, then the compiler would already know how to copy the object into the formal parameter, but the purpose of the copy constructor is to provide the code to copy the object, so its kind of a "cart before the horse" thing to think about call by value here.


How is solving for a specified variable in a formula different to finding a solution for an equation or inequality?

With a formula, you know the variable's value, and you have to calculate the value of the function of it. With an equation, you know the function's value, and you have to calculate the value of the variable.


How is solving for a specified variable in a formula similar to finding a solution for an equation or inequality?

With a formula, you know the variable's value, and you have to calculate the value of the function of it. With an equation, you know the function's value, and you have to calculate the value of the variable.


Why is parameter passing useful to programmers?

Because all software is written using functions and classes. If you do not know how to pass data from class to class, to function you are not a programmer.


How can you know that a value is the minimum of a function?

When the first derivative of the function is equal to zero and the second derivative is positive.


How do you know if a graph is a function?

A graph is a function if there is no more than one y-value for any x value. This means no vertical lines or "C" shapes, etc


How do you know when an ordered pair could not be in a function?

Evaluate the function at the first number in the pair. If the answer is not equal to the second value, then the ordered pair cannot be in the function.


How do you design a function named feetToinches that accepts a number of feet as an argument and returns the number of inches in that many feet?

You design it as an inline function with a constant unsigned reference parameter. Since there are 12 inches to the foot, the return value is the product of the parameter and 12. However, you must also ensure the return type has enough bits to store the result. C++ example: inline unsigned int feetToinches( const unsigned int & feet ){ return( feet < 357913941 ? feet * 12 : 0 ); } The above example assumes an int is 32-bits wide. If the input is larger than 357913941 (feet) then there won't be enough bits to store the result, so zero is returned instead. If the input is non-zero and the return is zero, you know the conversion failed. We use unsigned data types because you cannot have a negative unit of distance. We use a reference parameter to prevent the parameter from being copied (not strictly necessary if the type will fit within a pointer variable, but good practice nonetheless). The parameter is constant because the function does not need to modify the parameter. It is inline because the code is not complicated and is a prime candidate for inline expansion, thus eliminating the need for a function call altogether.


How can you tell something is a function when you are given values of the function?

If you know some values, then you at least have a function of some sort, but you don't know what other values might be. To be a useful function you must be aware that a rule exists to calculate its value for any situation, and preferably know what the rule (equation or whatever) is.


If f(1) 10 what is f(3)?

Not enough information. You can't deduce the function value at one point, from the function value at some other point, unless you know more about how the function is defined.


What is Parameter Passing and Returning values.. in Programming.. preferbly Visual Basic?

Parameters are the variables you pass to functions. Return values are the variables that are returned by those functions. Values can also be returned by the parameters themselves (such parameters are said to be output parameters).The variables you pass and return from functions will either be by value or by reference. Only references can be output parameters, since passing by value creates an automatic copy of the value which falls from scope when the function returns. Pointer variables are always passed by value. To pass a reference to a pointer you must pass a pointer to the pointer, which is itself passed by value, but refers to the pointer.Constant references are the preferred method of passing variables to functions, since there is no need to copy the variable you pass and because it is constant, the original value is left unaltered. Non-constant reference is the next best method, but only if you expect changes to be reflected back in your value (an output parameter). If you do not expect changes, then you must pass by value or, when that isn't an option, create a copy of your value and pass by non-constant reference. The only difference is that passing by value automatically destroys the copy when the function returns.Ignoring output parameters, a function can only return, at most, one value. A function that returns void has no return value, however it is good practice to always return something, even if only an integer to indicate whether the function was successful (zero) or not (non-zero). If the function is a logical function, such as Add( X, Y ), or an accessor, such as GetName() then it makes more sense to return the actual result of the function via the return value. If you need more than one return value, then you must use output parameters, passed by reference, which allows the return value to be used as an error indicator.Generally you will want to store the return value of a function, especially if the return value is a memory allocation. If you don't store the return value, the value is lost forever, unless you re-call the function with the same parameters, which is highly inefficient. However, if you only need to know the result of a function once, you don't need to store it, so long as you act upon it immediately, usually as part of a conditional expression. E.g.,int x, y; // Uninitialised, values unknown.if( x + y == 12 ) // call the int::operator+ function.// x+y is definitely 12.else// x+y is definitely not 12, but the actual sum is no longer known at this point.


How do you use a parameter on a energy meter?

arey jaffa if i know tujhe enduku poochtam ra