What is the difference between the form parameter and the actual parameter in c, please give an exam

Updated on educate 2024-03-12
20 answers
  1. Anonymous users2024-02-06

    The address assigned to the parameter and the parameter is different.

    If you don't use pointers or references, the argument can only pass something (value) to the parameter, just like the example above, the thing with the argument can be copied and moved to the parameter, and the thing (value) in the parameter is changed but not passed in reverse, that is, the thing in the parameter will not cover the thing (value) of the parameter;

    To put it simply, the address of the argument and the parameter operation are different, if you need to get the value to change, you generally use return to return the value, and if you want to change the argument, you will use a pointer or reference to achieve it, so that the manipulation of the address makes the argument more convenient;

    The scope of the parameter is limited to the defined function, and once the function is out, the defined parameter will be released.

  2. Anonymous users2024-02-05

    The parameters are the parameters used when creating the function, and the arguments are the corresponding parameters passed in according to the list of parameters of the function when using the function. When a function is declared, the name of the parameter can be the same as the parameter name when the function is implemented, or it can be different.

  3. Anonymous users2024-02-04

    A parameter has no practical meaning, it is the domain (or type) of the variable that defines the parameter.

    A real argument is a special case of a form argument, which is a valid value in the variable domain.

    For example: y = 5 - x (1x is the form parameter, and (1,5) is the value range of the form parameter, and any real number in the open interval from 1 to 5 can be a real parameter, that is, the real parameter is a definite value, and the form parameter is the value range of the real parameter.

    Another example: func a(int b){.}

    b is the formal parameter, and the value range of b is "integer", so any integer can be an argument of the function.

  4. Anonymous users2024-02-03

    Formal and practical parameters.

    The parameters of a function are divided into two types: form arguments and actual arguments. In this subsection, we will further introduce the characteristics of form parameters and actual parameters and the relationship between them. Parameters appear in the function definition and can be used in the entire body of the function, but cannot be used outside of the function.

    The arguments appear in the tonal function, and the arguments cannot be used after entering the modulated function. The function of the form and the actual parameters is to transmit data. When a function is called, the main key function transmits the value of the real argument to the shape parameter of the modulated function, so as to realize the data transmission from the main key function to the modulated function.

    The formal and practical parameters of a function have the following characteristics:

    1.The parameter variable allocates the memory cell only when it is called, and at the end of the call, the allocated memory cell is immediately released. Therefore, arguments are only valid inside the function. After the function call is completed, the key function can no longer be used.

    2.Arguments can be constants, variables, expressions, functions, and so on, and regardless of the type of quantification, they must have definite values when making a function call in order to pass those values to the parameters. Therefore, the parameters should be assigned and input in advance to obtain a definite value.

    3.The parameters and parameters should be strictly consistent in number, type, and order, otherwise the type mismatch error will occur.

    4.The data transfer that occurs in a function call is one-way. That is, the value of the argument can only be transmitted to the parameter, and the value of the argument cannot be transmitted to the argument in reverse. Therefore, during the function call, the value of the parameter changes, but the value of the argument does not.

    Example] can illustrate this problem.

    main()

    int s(int n)

    In this program, a function s is defined, and the function of this function is to find the value of ni. Enter the value n in the main function and pass it as an argument to the s function when called (note that in this case, the identifiers of both the argument variable and the argument variable are n, but these are two different quantities with different scopes). In the main function, use the printf statement to output the value of n once, and this n value is the value of the real argument n.

    In the function s, the printf statement is also used to output the n value once, and this n value is the last n value of 0 obtained by the form parameter. From the point of view of luck, the input n value is 100. That is, the value of the real argument n is 100.

    When this value is passed to the function s, the initial value of the parameter n is also 100, and the value of the parameter n becomes 5050 during the execution of the function. After the main function is returned, the value of the output argument n is still 100. It can be seen that the value of the real parameter does not change with the change of the form parameter.

  5. Anonymous users2024-02-02

    When designing a program module in a high-level language, the parameters (in parentheses) defined immediately after the module name are called morphological parameters (also known as imaginary parameters). When the module is called, in the key module, the arguments that appear after the name of the called module are called arguments. The process of replacing virtual parameters with real parameters is called the combination of virtual and real parameters, also known as changing parameters.

    Most high-level language parameter changes are done by the compilation system, such as C and Fortran. The parameter change in the basic language is done by the programmer. If only real arguments are allowed to pass to virtual arguments, it is called "one-way transfer", and the combination of virtual and real variables in C language is "one-way transfer".

    If virtual arguments are allowed to pass to real arguments at the same time, this is called "bidirectional passing", as is the case with subroutines defined by the Fortran language.

  6. Anonymous users2024-02-01

    1. Form Parameter Real Parameter

    The arguments that appear in the function definition are called parameters.

    The arguments that appear in the function call are called real arguments.

    2. For example: function definition:

    int max( int a , int b ) where a and b are the form parameters.

    Function calls. int main()

  7. Anonymous users2024-01-31

    The form parameter changes the value inside the function, and the pass parameter changes the value outside the function at the same time.

  8. Anonymous users2024-01-30

    Form parameters: It is abstract.

    Actual parameters: It is concrete.

  9. Anonymous users2024-01-29

    The fourth floor is all copied, and there are a lot of words.

  10. Anonymous users2024-01-28

    In C, because the function is called, there is an interface problem.

    A function is used to implement a function, such as: include

    int add(int a,int b) adds two numbers to int main().

    It is equivalent to a machine that processes data, and data is the raw material, which requires an input port of materials, which is the interface of function design, in this process we first define a function add(int a,int b) (made a machine), when defining this function, because we just give it the function of adding two numbers, but we don't know that it will add the two numbers, so we first set it to add a, b, (just like we just built a machine, knows what it does without raw materials) in this case a and b are the form parameters, that is, it is just a formal data, which is defined in the function.

    The real argument is to pass the value to the form parameter when calling the function, such as num1, num2, (it is the raw material that the machine needs when it is to start, and the machine can only process it with it), we actually want to add num1 and num2, but it is too complicated to write ** in the main function, so write ** into the function. At this time, the parameters a and b are given the values of num1 and num2, and they can replace num1 and num2 to complete the operation they want to do on num1 and num2 in the add function body (as for why the arguments are used, the scope of the data is also involved).

  11. Anonymous users2024-01-27

    There are the following differences:1. The main body is different: When the argument is called, the parameter in parentheses after the function name is "actual parameter". Parameters are not actual variables, also known as dummy variables.

    2. Different purposes: Arguments can be constants, variables, or expressions, and no matter what type of quantity the arguments are, they must have definite values when making a function call, so that these values can be transmitted to the parameters.

    It should be noted that when the parameters and arguments are not pointer types, when the function is running, the arguments and arguments are different variables, they are located in different positions in memory, and the arguments make a copy of the content of the arguments, and the arguments are released at the end of the function, while the arguments do not change.

  12. Anonymous users2024-01-26

    intfun(intn)int

    main()

    In this example, n is a form argument, which is not a concrete argument in the main function.

    i is the real argument, which is defined in the main function, i.e. there is the actual entity in memory, and in the fun function, it is passed in as n.

    The distinction is simple, and the parameters are defined in a custom function, such as n. Arguments, on the other hand, are arguments that need to be passed in when calling a function, such as i.

  13. Anonymous users2024-01-25

    For example: int

    func(int

    a,intb)

    intmain()

    where a and b are the formal arguments and x and y are the actual arguments. Formal arguments are used when the function is implemented, while actual arguments are used to pass the value to the formal argument when the function is called and then execute the function.

  14. Anonymous users2024-01-24

    A parameter is a random name given to a parameter when a function is defined, just to distinguish it from other variables.

    The argument is what is actually passed to the function when the function is called.

  15. Anonymous users2024-01-23

    fun(inta)(a

    1);Here a is the form reference. inta;

    Defining a variable A is to create a space in memory to store the value of a. A then the value stored in this space is 4, which exists, and even if a is not assigned to the memory, it still leaves a place for it.

    Of course, it's a value.

    Formal arguments don't create space for it.

    And when you pass a value into this function: fun(4); At this point, a was given space to store the value of 4.

    For example, main() will pass the value of n to a memory at this time, and will create space for it to store the value of 5 to implement the function of this function.

  16. Anonymous users2024-01-22

    Parameters. : can be thought of as internal to the function.

    Local variables. Actual parameters.

    Actual parameters. Value, which is the value that is actually passed to the function externally. This value is the direct representation of the parameter in the function.

  17. Anonymous users2024-01-21

    Parameters: The full name of "formal parameters" is the parameter used when defining the function name and function body, and is used to receive the parameters passed when the function is called.

    The function of the form parameter is to realize the connection between the main tone function and the modulated function, and usually the data processed by the function, the factors affecting the function of the function or the result of the function processing are used as the form parameters.

    Actual Parameters: Full name"Actual parameters. "is the parameter that is passed to the function at the time of call, that is, the value passed to the called function.

    Arguments can be constants, variables, expressions, functions, and so on, and regardless of the type of quantification, they must have definite values when making a function call in order to pass those values to the parameters. Therefore, the parameters should be assigned and input in advance to obtain a definite value.

  18. Anonymous users2024-01-20

    Every time a function is called, Laidu Source will recreate the formal parameters that the function has, and the actual arguments passed by the pass will initialize the corresponding formal dao

    Ginseng. The initialization of the parameters is the same as the initialization of variables: if the parameters have a non-referential type, the values of the arguments are copied; If the parameter is a reference type, it is just an alias for the argument.

    For more information about the definition of functions and the difference between non-referential parameters and referential parameters, see C++ Primer

  19. Anonymous users2024-01-19

    To put it simply, the form parameters and actual parameters are used to complete the data transmission in the function and digital modulation.

    Function definitions use form parameters.

    The argument used by the main function to call the function, which passes the value of the argument to the form argument.

  20. Anonymous users2024-01-18

    The first floor has said a lot, and there are a lot of such content pages in the book, take a look, and there is also to write the subfunction yourself to see, what is the difference between the parameters in the subfunction and the parameters defined by the main function.

Related questions
7 answers2024-03-12

Fabrics and woven fabrics have their own unique characteristics in terms of processing technology, cloth structure, fabric characteristics, and finished product use due to their different weaving methods. The specific differences are as follows: >>>More

3 answers2024-03-12

What is the difference between a Buddha and a Bodhisattva?

12 answers2024-03-12

From a botanical point of view, "Rosa chinensis" is an erect shrub with barky thorns, smooth leaves, flowering in all seasons, and more flower colors; "Rose" (rosa rugosa) is also an erect shrub, but its branches are prickly and bristle, and its leaves are wrinkled, and it blooms in the spring and its flowers are mostly purple-red and white. Therefore, it is obviously wrong to equate "moon flowers" with "roses". >>>More

8 answers2024-03-12

24What is the difference between cold dew and white dew in the solar terms? The rural uncle explained very clearly, how much do you know.

7 answers2024-03-12

First of all, BRT and bus travel on different roads.

The BRT has dedicated lanes, while buses have one lane with social buses. >>>More