PROGRAM TO SWAP TWO NUMBRES USING FUNCTIONS

/*PROGRAM TO SWAP TWO NUMBRES USING FUNCTIONS*/
#include<stdio.h>
#include<conio.h>
void swap(int *, int *);
void main()
{
int a,b;
clrscr();
printf(“Enter any two numbers: “);
scanf(“%d%d”,&a,&b);
printf(“Before swapping numbers are: a=%d, b=%d\n”,a,b);
swap(&a,&b);
printf(“After swapping numbers are: a=%d, b=%d”,a,b);
getch();
}
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}

Leave a Reply

Your email address will not be published. Required fields are marked *