Social Icons

Saturday, 15 February 2014

Program to swap two numbers without using third variable

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int a,b;
cout<<"\n Enter value of a : ";
cin>>a;
cout<<"\n Enter value of b : ";
cin>>b;

a=a+b;
b=a-b;
a=a-b;

cout<<"\n a = "<<a;
cout<<"\n b = "<<b;
getch();
}

                                                        Output



No comments:

Post a Comment