Write a c program for swapping of two numbers using function?
#include<stdio.h>
#include<conio.h>
int swap(int *, int *); // prototype
int main()
{
int x, y, result;
printf("Enter two numbers: ");
scanf("%d %d",&x, &y);
swap(&x, &y);
printf("x: %d \ny: %d", x, y);
getch();
}
int swap(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
Comments