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

Popular posts from this blog

Binary Search, Linear Search, Selection Sort and Bubble sort Python Menu Program

Housie/Tambola using Python with Tickets in PDF file

100% Working C++ Tambola/Housie Code with 90 Unique Numbers