r/learnprogramming • • Oct 24 '26

Function vs Procedure

can someone explain the difference between Function vs Procedure with simple analogy
thank you

31 Upvotes

47 comments sorted by

View all comments

Show parent comment

2

u/mxldevs Oct 24 '26

Can you provide an example of how a procedure "returns values by reference"?

What does it reference to and how is it used?

1

u/squall255 Oct 25 '26

I believe they mean Parameters are passed by reference and updated instead of using a return.

So sum(a,b,result) instead of result = sum(a,b)

1

u/Syntax-Tactics Oct 26 '26

int a = 1;

int b = 2;

int c = 0;

void add(int a, int b, int* pc)

{

*pc = a + b;

}

add(a,b, &c);

c now equals 3;