How to swap using function by C

#include<stdio.h>
#include<conio.h>
void swap ( int a ,int b) ;
void pswap (int *a ,int *b);
void main ()
{
int x=1,y=2;
clrscr();
printf(“%d,%d\n”,x,y);
pswap(&x,&y);
printf(“%d,%d\n”,x,y);
getch();
}
void swap (int a,int b)
{
int t;
t=a;
a=b;
b=t;
printf(“%d,%d\n”,a,b);
}
void pswap ( int *a, int *b)
{
int t;
t=*a;
*a=*b;
*b=t;
printf(“%d,%d\n”,*a,*b);
}

After Running Program 🙂

Leave a Reply