PROGRAM TO SWAP TWO NUMBERS WITHOUT USING A THIRD VARIABLE IN C PROGRAMMING
This eveyone computer science student must have encountered.
void main()
{
int a,b;
printf("PLEASE ENTER THE TWO NUMBERS:");
scanf("%d %d",&a,&b);
/*little bit of maths*/
a=a+b;
b=a-b;
a=a-b;
printf("THE SWAPPED NUMBERS ARE:");
printf("%d %d",a,b);
getch();
}
No comments:
Post a Comment