Wednesday, August 24, 2016

Swapping Two Numbers using Third Variable in C++

#include<iostream>
using namespace std;
int main()
{
int a = 5, b = 10, c;
    cout << "Before swapping" << endl;
    cout << "a = " << a << ", b = " << b << endl;
    c = a;a = b;b = c;
    cout << "After swapping" << endl;
    cout << "a = " << a << ", b = " << b << endl;
return 0;
}



Do Comment,Share :)
Sharing is Caring ;)

No comments:

Post a Comment