Tuesday, December 6, 2011

Write a C Program to swapping without third variable

#include <stdio.h>
#include <conio.h>
void main()
{
 int a,b;
 clrscr();
 printf("Enter value for a and b: ");
 scanf("%d %d",&a,&b);
 a=a+b;
 b=a-b;
 a=a-b;
 printf("\nAfter swapping a and b: %d %d",a,b);
 getch();
}

No comments:

Post a Comment