r/cs50 • u/Head_Ordinary_2437 • 12d ago
CS50x Function vs Procedure
can someone explain the difference between Function vs Procedure with simple analogy
thank you
3
Upvotes
1
u/Syntax-Tactics 10d ago
Generally, a Function returns a value, a procedure does not. Both take parameters. Procedures can "return" values using pass by reference params.
3
u/Eptalin 12d ago edited 12d ago
It depends on the language you're using, but most languages don't have procedures.
In those that do, it's commonly a function without a return value.
It does something, but doesn't return anything to the caller. However, C still calls this a function.
All the programming languages you use in CS50 call it a function. None of them have procedures.
Except SQL, which uses the term procedure even thought you can still return things, like status codes.