Call by value in c programming?

Its way of passing arguments to a function.In this method the value of actual arguments(the arguments in the function call)remains unchanged. changes that we make are effected only to the formal arguments.

eg.

#include<stdio.h> void modify(int,int);// function prototype. this is given to make the compiler aware that there is a function modify. if we didnt do this a error will be shown. otherwise the function body should be written before the function call

main()

{

int a,b;

printf("enter two numbers");

scanf("%d %d",&a,&b);

modify(a,b);// function call the parameters a and b are actual arguments.

printf(" a and b in the main %d and %d",a,b);

}

void modify(int a,int b)// function header the parameters no1 and no2 are called as formal arguments.

{

a=a*3;

b=b*3;

printf(" a and b in function %d and %d",a,b

}

output:

enter two numbers

3

2

a and b in function 9 and 6

a and b in the main 3 and 2.

this is a program to multiply 3 to the numbers given by the user . here we use function and the arguments are passed by call by value method.here the value of the formal arguments are altered withinthe function but no change happens to the actual arguments . the values in the main does change even after the function call.