Saturday, June 29, 2013

Write a C program to Swap two numbers without third variable.



#include <stdio.h>
 
void main()
{
   int a, b;
  printf("Enter two integers to swap\n");
   scanf("%d%d", &a, &b);
   a = a + b;
   b = a - b;
   a = a - b;
   printf("a = %d\nb = %d\n",a,b);
}

No comments:

Post a Comment