Call by Value
Call by value in C is where in the arguments we pass value and that value can be used in function for performing the operation. Values passed in the function are stored in temporary memory so the changes performed in the function don’t affect the actual value of the variable passed.
Example:
C
// C Program to implement // Call by value #include <stdio.h> // Call by value int sum( int x, int y) { int c; c = x + y; // Integer value retured return c; } // Driver Code int main() { // Integer Declared int a = 3, b = 2; // Function Called int c = sum(a, b); printf ( "Sum of %d and %d : %d" , a, b, c); return 0; } |
Output
Sum of 3 and 2 : 5
C Function Arguments and Function Return Values
Prerequisite: Functions in C
A function in C can be called either with arguments or without arguments. These functions may or may not return values to the calling functions. All C functions can be called either with arguments or without arguments in a C program. Also, they may or may not return any values. Hence the function prototype of a function in C is as below:
Contact Us