Loading

C Program to Swap Two Numbers without Temporary Variable

C -Program to Swap Two Numbers without Temporary Variable



#include<stdio.h>
#include<conio.h>

void main()
{
   int x,y;
   clrscr();
   printf("\n Enter Value of x :: ");
   scanf("%d",&x);
   printf("\n Enter Value of y :: ");
   scanf("%d",&y);
   printf("\n Before Swapping\n");
   printf("\n x :: %d\t\ty :: %d",x,y);
   x=x+y;
   y=x-y;
   x=x-y;
   printf("\n\n After Swapping\n");
   printf("\n x :: %d\t\ty :: %d",x,y);
   getch();
}

This entry was posted in . Bookmark the permalink.

Leave a reply