// Write a program to interchange the values of two variables without using a third variable
#include<iostream.h>
#include<conio.h>
void main( )
{
int a, b;
clrscr( );
cout<<"Enter the two numbers:\n";
cin>>a>>b;
cout<<"Before Interchanging : a ="<<a<<" and b = "<<b<<endl;
a = a + b ;
b = a - b ;
a = a - b ;
cout<<"After Interchanging : a ="<<a<<" and b = "<<b<<endl;
getch();
}
Write a program to interchange the values of two variables without using a third variable
Reviewed by Vision Academy
on
February 20, 2022
Rating:

No comments: