DESCRIPTION-:THIS PROGRAM INTERCHANGE THE TWO NUMBER WITHOUT USING THE THIRD VARIABLE.THIS PROGRAM ACCEPT TWO NUMBERS AS INPUT AND GENERATE TWO NUMBER IN OUTPUT BY SWAPPING THEIR VALUES.
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"enter the value of a and b";
cin>>a>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"\n"<<"after interchanging value of"<<"a="<<a<<"\n"<<"b="<<b;
getch();
}
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"enter the value of a and b";
cin>>a>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"\n"<<"after interchanging value of"<<"a="<<a<<"\n"<<"b="<<b;
getch();
}
0 comments:
Post a Comment