C++ Program to Swap Values of 2 Variables
//swapping values
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
float a,b;
cout<<"Enter the value of a : ";
cin>>a;
cout<<"Enter the value of b : ";
cin>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"Value of a after swapping is "<<a<<endl;
cout<<"Value of b after swapping is "<<b<<endl;
return 0;
}
Comments
Post a Comment