How can I pass global variables into a function?

Which of the following is true "In case of pass by reference" (C programming)?

  • In case of pass by reference 1. The location of variable in memory is passed to the function so that it can use the same memory area for its processing 2. The function declaration should contain ampersand (& ) in its type declaration 3. All of above 4. The values of those variables are passed to the function so that it can manipulate them i think it's 3 but i may be getting the pass/call confused. thanks.

  • Answer:

    3. All of above The value of the variable REMAINS in place. All that is passed is an "address" to the variable in memory. When the function manipulates the variable, the background function has its variable value changed as well. #2 is correct because that *is* the syntax. #4 is incorrect, and is precisely why "all of the above" isn't the last choice.

Joe S at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

3. All of above The value of the variable REMAINS in place. All that is passed is an "address" to the variable in memory. When the function manipulates the variable, the background function has its variable value changed as well. #2 is correct because that *is* the syntax. #4 is incorrect, and is precisely why "all of the above" isn't the last choice.

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.