Computer Science, asked by yukthanagalla979, 9 months ago

What is a function explain with a suitable example and define call by value and pass by reference methods of parameter passing?

Answers

Answered by sharmaprisha2233
4

Answer:

Call by Reference: Both the actual and formal parameters refer to same locations, so any changes made inside the function are actually reflected in actual parameters of caller.

Call By Value: In this parameter passing method, values of actual parameters are copied to function’s formal parameters and the two types of parameters are stored in different memory locations. So any changes made inside functions are not reflected in actual parameters of caller.

Answered by sgs07
2

Answer:

function is lines of code to do a particular task.

so to add 2 numbers we can write a func.

add(a,b)

{

c=a+b;

return c;

}

Explanation:

here c is addition and is returned by function.

call by value: u can directly use value of a and b.

ex: add(5,6)

or refer it.

n1=6

n2=7

add(n1,n2)

simple!

Similar questions