Friday, September 23, 2011

WAP to swap two numbers without using third variable


/*
  Name: WAP to swap two numbers without using third variable
  Author: Parveen Malik
  Date: 23/09/11 11:34
*/
#include <stdio.h>
#include <conio.h>
 int main()
 { 
     int x,y;
     printf("Enter the value of x and y \n");
     scanf("%d%d",&x,&y);
     printf("Before swapping\nx = %d\ny = %d",x,y);
     x=x+y;
     y=x-y;
     x=x-y;
     
     printf("\nAfter swapping\nx = %d\ny = %d\n",x,y);
     getch();
             return 0;
             }

OUTPUT : 

0 comments:

Post a Comment