Computer Science, asked by jasskarno9, 2 months ago

write a program to swap the value of two variables (using third variable)

Use only number1, number2 and swap_number as variable names

Answers

Answered by SurajRaj21
1

Answer:

//Swap with three variable

#include <iostream>

using namespace std;

int main()

{

int a, b, c;

cout<<" enter two numbers :"<<endl;

cout<<" ";

cin>>a>>b;

cout << "Before swapping." << endl;

cout <<" "<<"a = " << a<<endl<<" " << "b = " << b << endl;

c = a;

a = b;

b = c;

cout << "\nAfter swapping." << endl;

cout <<" "<< "a = " << a<<endl <<" "<< "b = " << b << endl;

return 0;

}

Similar questions