C++ tutorial, C++ programs, C++ Exercises, C++ Example Programs

Showing posts with label Program Exchange Values Without Third Variable. Show all posts
Showing posts with label Program Exchange Values Without Third Variable. Show all posts

Tuesday, October 29, 2013

Program Exchange Values Without Third Variable


#include<iostream.h>
#include<conio.h>
void main()
{
     int v1, v2;

     cout<<"Enter value of first variable:";
     cin>>v1;
  
     cout<<"Enter value of second variable:";
     cin>>v2;

     cout<<"The values before swapping are: \n Varible 1="<<v1<<" Variable 2="<<v2;
     v2 = v1+v2;
     v1 = v2-v1;
     v2 = v2-v1;

     cout<<"\n The values after swapping are: \n Varible 1="<<v1<<" Variable 2="<<v2;  
     
      getch();

     }
Share:

EasyCPPprogramming.blogspotcom

Labels