Advertisement
Mahmoud_Hawara

Swap between two given numbers

Oct 28th, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     cout << "Program to swap between to given numbers\n";
  7.     cout << "----------------------------------------\n";
  8.     cout << "Enter the first number: ";
  9.     int a;
  10.     cin >> a;
  11.     cout << "Enter the second number: ";
  12.     int b;
  13.     cin >> b;
  14.     int temp = a;
  15.     a = b;
  16.     b = temp;
  17.     cout << "\nAfter Swapping.....\n\n";
  18.     cout << "The first number is " << a << '\n';
  19.     cout << "The second number is " << b << '\n';
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement