Ask Question
2 June, 05:47

Suppose a variable is passed By Value to a parameter of a Sub procedure, and the parameter has its value changed inside the Sub procedure. What will the value of the variable be after the Sub procedure has executed?

+2
Answers (1)
  1. 2 June, 05:54
    0
    "The value of the variable will remain the same which is already have when the sub-processor is called".

    Explanation:

    The above question said that:-

    void fun (int a)

    {

    a=a+1;

    }

    void main ()

    {

    int a=5;

    fun (a);

    }

    //what will be the value of a in the main function after the fun function is excuted.

    Then the answer is: the value of a will be 5 in the main function. It is because when the fun function is called, then a variable that is defined in the fun function is a local variable for fun function. That scope after the fun function is null. The a variable inside the fun function is a different variable and the main function a variable is also a different variable. So when the user prints the value of a variable inside the fun function, it will give the result as 6. But when he prints the value of a variable inside the main function, then it will give the value as 5.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Suppose a variable is passed By Value to a parameter of a Sub procedure, and the parameter has its value changed inside the Sub procedure. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers