Program to find Swap of 2 numbers in c
#include <stdio.h>
void swap(int*, int*);
int main()
{
int x, y;
printf("Enter the value of x : \n");
scanf("%d",&x);
printf("Enter the value of y : \n");
scanf("%d",&y);
printf("Before Swapping x & y is : \n x = %d \n y = %d \n", x, y);
swap(&x, &y);
printf("After Swapping x & y is : \n x = %d \ny = %d ", x, y);
return 0;
}
void swap(int *a, int *b)
{
int temp;
temp = *b;
*b = *a;
*a = temp;
}
Comments