diff --git a/swap.c b/swap.c index d72ac47..74676da 100644 --- a/swap.c +++ b/swap.c @@ -1,5 +1,11 @@ #include +def swap(*x,*y) +{ + int temp =x; + *x=*y; + *y=temp; +} int main() { //hello world @@ -9,10 +15,8 @@ int main() printf("\nEnter Value of y "); scanf("%d", &y); - int temp = x; - x = y; - y = temp; + swap(&x,&y); printf("\nAfter Swapping: x = %d, y = %d", x, y); return 0; -} \ No newline at end of file +}