-->

Header Ads

Swapping of two numbers in c without using third variable:

C Program (code)

#include
#include

void main()
{
clrscr();
inta,b;
printf("Enter two number which you want to swap : \n") ;
scanf("%d%d",&a,&b);
printf("\nBeforeswaping values a = %d\tb = %d\n",a,b);
a=a+b;
b=a-b;
a=a-b;

printf("After swaping new value :\n a = %d\tb = %d",a,b);
getch();
}

Output of c program:

No comments

Powered by Blogger.