9 Jan 2015

SWAP TWO NUMBERS WITH OUT USING THIRD VARIABLE



#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the 1st value :-\n");
scanf("%d",&a);
printf("Enter the 2nd value :-\n");
scanf("%d",&b);
printf("\nBefore swap the value of a=%d and b=%d\n",a,b);
b=a+b;
a=b-a;
b=b-a;
printf("After swap the value of a=%d and b=%d\n",a,b);
getch();
}

No comments:

Post a Comment