Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Swap two Numbers

 C++ Program to Swap to integer value.This program asks user to enter two numbers and this program will swap the value of these two numbers.
Simply use oh three variable as shown in the program a, b & temp.
external variable temp is use to hold the value of a so that it can be use to assign value to b variable.


Source Code:-

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

void main()
{clrscr();
 int a,b,temp=0;
 cout<<"Program to swap two number by-Tarun Rawat\n\n";
 cout<<"Enter first number (let a)  : ";
 cin>>a;
 cout<<"\nEnter second number (let b) : ";
 cin>>b;
 temp=a;
 a=b;
 b=temp;
 cout<<"\nAfter swap :- ";
 cout<<"\n\t\tValue of a is : "<<a<<"\n\n\t\tValue of b is : "<<b;
getch();
}

No comments:

Post a Comment

Blogger Widgets

Find Us On Google, Just type - way2cplusplus -

If you have any questions on implementing or understanding this C++ Program , shoot me a comment and I'll be glad to help! :) :)