Page 1 of 1

PROJECT: Swaping in Two Variables

Unread postPosted: Thu May 22, 2008 6:03 pm
by rajeevmahura
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter Any Number For a:- ");
scanf("%d",&a);

printf("Enter Any Number For b:- ");
scanf("%d",&b);

printf("\nAfter Swaping\na= %d\nb= %d",a,b);

a=a+b;
b=a-b;
a=a-b;

printf("\nBefore Swaping\na= %d\nb= %d",a,b);
getch();
}
----------------------------------
Input: a=4,b=6
Output:After Swaping
a= 4
b= 6
Before Swaping
a= 6
b= 4