Programing code to Interchange numbers in C++.

This program ask to the user to enter two numbers (value of First and Second ) to interchange and display the result on the screen .

 

Let’s open turboC++ and write the following Code:

 

// Code:

 

#include<iostream.h>

#include<conio.h>

void main()

{

     float    a,b,temp;

    clrscr();

     cout<<”enter first number:”;

    cin>>a;

    cout<<”enter second number:”;

    cin>>b;

    temp=a;

    a=b;

    b=temp;

    cout<<”interchanged numbers are: \n first number is:”<<a <<”\n”<<” second number is :”<<b;

    getch();


}

 

 

Now, Run the Program and see Output:

 

 

Output:

 

 

OUTPUT

 

 

Happy coding…

 

 

 

 

Tags: , ,