c program for call by value

C program to swap two numbers using call by value technique.


int swap(int, int);

void main()
&nbsp; int a= 30, b=20;
&nbsp; swap(a,b);
&nbsp; printf("a=%d b=%d", a, b);
&nbsp; getch();

int swap(int x, int y)
&nbsp; int t;
&nbsp; t = x;
&nbsp; x = y;
&nbsp; y = t;
&nbsp; printf("x=%d y=%d", x, y);


x=20 y=30
a=30 b=20

after swapping the value will be changed on X & Y. See the value of A & B is not changed.

READ  Fibonacci series in c

Leave A Comment

Your email address will not be published. Required fields are marked *