Muhammad Imran Ansari
What are different types of arguments? (Call by Value, Call by Reference)

What are different types of arguments? (Call by Value, Call by Reference)

By Muhammad Imran Ansari in OOP/OOD on Jan 18 2023
  • Tuhin Paul
    Apr, 2023 15

    Call by value is a mechanism where a copy of the argument value is passed to the function or method. This means that any changes made to the argument inside the function or method will not affect the original value outside of the function or method. In other words, the function receives a copy of the value, rather than the original value itself. This is the default behavior for many programming languages, including C, Java, and Python.

    Call by reference is a mechanism where a reference or pointer to the original value is passed to the function or method. This means that any changes made to the argument inside the function or method will affect the original value outside of the function or method. In other words, the function receives a reference to the original value, rather than a copy of the value itself. This is commonly used in languages such as C++ and C#.

    • 2
  • Tuhin Paul
    Apr, 2023 15

    There is also a third type of argument, called call by name, which is less common and is used in languages such as Algol and Haskell. In call by name, the argument is not evaluated until it is used inside the function or method. This means that the argument is effectively passed as an expression, rather than as a value or a reference.

    Each type of argument passing mechanism has its own advantages and disadvantages, and the choice of which one to use depends on the specific requirements of the program and the language being used. Call by value is simpler and less error-prone, while call by reference is more flexible and allows for more efficient use of memory.

    • 1
  • Munib Butt
    Jan, 2023 26

    I have mostly used 3 types of arguments: 1. By value 2. By Reference 3. Output

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS