C++ Program to Swap Two Numbers
To swap two numbers we will use another temporary variable to store the value of first number.
- //C++ Program to swap two numbers"
-
- #include <iostream>
- using namespace std;
-
- int main()
- {
- int a, b, c;
- cout<<"Enter first number: ";
- cin>>a;
-
- cout<<"Enter second number: ";
- cin>>b;
-
- c=a;
- a=b;
- b=c;
-
- cout<<"Swapping of the numbers are= "<<a <<" "<< b;
- return 0;
- }
Output
