Call by value program
Program
#include <stdio.h> int increment(int var) { var = var+1; return var; } int main() { int num1=30; int num2 = increment(num1); printf("num1 value is: %d", num1); printf("\nnum2 value is: %d", num2); return 0; }
Output:
num1 value is: 30 num2 value is: 31
Explanation
We passed the variable num1 while calling the method, but since we are calling the function using call by value method, only the value of num1 is copied to the formal parameter var. Thus change made to the var doesn’t reflect in the num1.
0 Comments
à°®ీà°•ు edit à°šేà°¸ి à°«ొà°Ÿోà°¸్, à°µీà°¡ిà°¯ోà°¸్, à°‡ంà°•ా à°¦ెà°¨ి à°—ుà°°ింà°šి à°…à°¨్à°¨ా ఇన్à°«à°°్à°®ేà°·à°¨్ à°•ాà°µాà°²ీ à°…ంà°Ÿే Plz comment à°šేà°¯ంà°¡ి