programming-examples/c/Data_Input_Output/C Program to Program to swap values of two integers without using a temporary variable.c
2019-11-15 12:59:38 +01:00

31 lines
469 B
C

/* swap - program to swap values of two integers without using a temporary variable */
#include <stdio.h>
#include <conio.h>
void main()
{
int x, y ;
clrscr() ;
printf("Enter two integers: ") ;
scanf("%d %d", &x, &y) ;
printf("x=%d y=%d \n", x, y) ;
x=x+y ;
y=x-y ;
x=x-y ;
printf("After swapping: \n") ;
printf("x=%d y=%d", x, y) ;
getch() ;
}
/*
Output:
Enter two integers: 5 8
x=5 y=8
After swapping:
x=8 y=5
*/