Tuesday, 14 February 2017

Swap two number in Turbo C+

Tags

//swap two numbers using three variables.


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

void main()
{

int a,b,c;
clrscr();

cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;

c=a;//assigning value in c and c is temporary variable.

a=b;

b=c;//assigning value of c  in b.

cout<<"after swapping a:"<<a<<"\nb:"<<b;

getch();
}