QQ1. Explain the differences between call-by-value and call-by-reference in C. Write separate C programs to swap two numbers using both approaches and analyze the output. Which approach reflects the changes outside the function and why?
- Call-by-value passes copies of arguments; original variables remain unchanged.
- Call-by-reference passes memory addresses (pointers) of arguments.
- Changes made in a call-by-value function affect only local copies.
- Changes made via dereferenced pointers in call-by-reference affect original variables.
Answer: In C programming, the mechanism by which arguments are passed to functions significantly impacts how data is handled. Two primary methods are call-by-value and call-by-reference, as discussed in Block 2, Unit 5 of MCS-011, which details function parameter passing techniques. Call-by-value involves passing copies of the actual parameter values from the calling function to the formal parameters of the called function. Any modifications made to these formal parameters within the function do not af...