main()
{ void swap(int,int);
int num1,num2;
char ch;
do{
clrscr();
printf("\n Enter two numbers one by one:-\n");
scanf(%d %d",&num1,&num2);
printf("\n Before swaping The Two Numbers are:-%d , %d",num1,num2);
swap(num1,num2);
printf("\n Want to continue? (Y/N):");
ch=getch();
}
while(ch=='y' || ch=='Y');
getch();
}
void swap(int n1,int n2)
{
n1=(n1+n2)-n1;
n2=(n1+n2)-n2;
printf("\n After swaping two numbers become %d , %d",num1,num2);
}
swapping two numbers without using 3rd variable
ReplyDeleteuse this example and write the code
code
a=10, b=5.
a= a+b;
b=a-b;
a=a-b;
check this koyel
this is ranjith u can reach at this mail id:rangthrocks@gmail.com