Computer Science, asked by krithigaC, 1 year ago

how to write an algorithm in C++ for swapping 2 numbers ?

Answers

Answered by victoriya
1
#include <iostream>
using namespace std;
int main()
{
int a = 5, b = 10, temp;
cout << "Before swapping." << endl;
cout << "a = " << a << ", b = " << b << endl;
temp = a; a = b; b = temp;
cout << "\nAfter swapping." << endl;
 cout << "a = " << a << ", b = " << b << endl;
 return 0;
}



Similar questions