Swapping of Two Numbers without Third Variable
February 20, 2012
/*
Write a program in C for Swapping of two numbers without third variable
*/
#include<stdio.h>
main()
{
int a, b;
printf("Enter two numbers to swap ");
scanf("%d%d",&a,&b);
a = a + b;
b = a - b;
a = a - b;
printf("a = %d\nb = %d\n",a,b);
return 0;
}
0 Comments