Thursday, 21 June 2012

write a c program to calculate swap of array by using call by reference


/*program to calculate swap of array by using call by reference */
#include<stdio.h>
#include<conio.h>
void main()
{
void swap(int*,int*);
int a,b;
clrscr();
printf("enter the two number");
scanf("%d%d",&a,&b);
printf("\nthe value of a &b is before swapping is %d\t%d :",a,b);
swap(&a,&b);
printf("\nthe value of a & b is after swapping is %d\t%d :",a,b);

getch();
}
void swap(int *a, int *b)
{
int *temp=0;
*temp=*a;
*a=*b;
*b=*temp;
return(a,b);
}

No comments: