Monday, 22 April 2013

Taking two inputs in variables and then interchanging their values

Description:

In c++, to take inputs from user 'cin' operator is used and to show output 'cout' operator is used.

Code:


#include<iostream>
#include<conio.h>
#include<iomanip>
using namespace std;
int main()
{
    int a,b,c;
    cout<<"Enter value of A"<<endl;
    cin>>a;
    cout<<endl;
    cout<<"Enter value of B"<<endl;
    cin>>b;
    c=a;
    a=b;
    b=c;
    cout<<"interchanged values are"<<endl;
    cout<<a<<endl<<b<<endl<<"ok";
    getche();
    return 0;
    }


Output:


No comments:

Post a Comment