call by value in C program by R4R Team

Call by value:
-Here call by value refers as we call the function and pass the variable value instead of passing refrence of variable.

program-

#include< stdio.h>
int func(int a, int b)
{
int t;
t=a;
a=b;
b=t;
}
int main() {
int i,j;
printf("Enter two numbers\n");
scanf("%d%d",&i,&j);
printf("Before function calling\n");
printf("%d %d",i,j);
func(i,j);
printf("After function calling");
printf("%d %d",i,j);

}


output-

Enter two number
3 4
Before function calling
3 4
After function calling
3 4

-In this program, firstly we take an input of two integer number.
-We pass value in function and this called as call by value.
-There is no change in actual input value by calling the function.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!