BCA

C AND LINEAR DATA STRUCURE

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6

PART C

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 . .

3.Program to swap two integers using function with call by value and call by reference mechanism.

      

#include< stdio.h >
 
void swap_by_value(int x,int y)
 
{
int m=x;
x=y
y=m;

 
}
void swap_by_reference(int *x,int *y)
 
{
int m=*x;
*x=*y;
*y=m;
}
void main()
{

int a=20,b=30;
 
printf("a=%d b=%d before function call \n",a,b);
swap_by_value(a,b);

printf("a=%d b=%d after call by value function call\n",a,b);
swap_by_reference(&a,&b) ;
printf("a=%d b=%d after call by reference function call\n",a,b);
 
}