Write a Program to Swap Two Numbers Without Using Third Variable

Program to swap two numbers without using Third Variable. Here we are using two variables of into the type.


#include<stdio.h>

int main()

{

              int a=10,b=20;

              Printf(“without swapping %d %d”,a,b);

              a=^b;

               b=^a;

               a=^b;

              printf(“after swapping %d %d”,a,b);

              getch();

}





Output:-a=20,b=10





0 comments:

Post a Comment

Don't Forget to comment