Swap Function In C

Swap Function In C

Swap Function In C




Program :
Swap Function In C





#include
#include
void swap(int*a,int*b);
void main()
{
int a,b;
clrscr();
printf("Enter the value of a and b is:");
scanf("%d%d",&a,&b);
printf("\n Before swapping");
printf("\n The given value of a is %d",a);
printf("The given value of b is %d",b);
swap(&a,&b);
printf("\n After swapping");
printf("\n The given value of a is %d",a);
printf("\n The given value of b is%d",b);
getch();
}
void swap(int*a,int*b);
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}

Post a Comment

1 Comments