Friday, 11 December 2015

Write a program that input two numbers to swap them

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int a,b,temp;
cout<<"Enter two numbers to swap them"<<endl<<endl;
cout<<"Enter first number"<<endl;
cout<<"a = ";cin>>a;
cout<<"Enter the 2nd number"<<endl;
cout<<"b = ";cin>>b;
cout<<"Input numbers as ("<<a<<","<<b<<")"<<endl;
temp=a;
a=b;
b=temp;
cout<<"after swapping ("<<a<<","<<b<<")"<<endl;
getch();
}

No comments:

Post a Comment