Write a program to swap two values in C++. (example: 50, 24)
Anonymous:
no madu
Answers
Answered by
2
Really simple.
Just keep in mind that I'm gonna skip the Header files and assume I'm writing in Turbo C++ .
void main ()
{
int a,b;
cout<<"enter 2 numbers to be swapped";
cin>> a>>b;
int temp; //temporary variable for swapping
temp =a;
a=b;
b=temp;
cout<<a<<b;
} // main
Just keep in mind that I'm gonna skip the Header files and assume I'm writing in Turbo C++ .
void main ()
{
int a,b;
cout<<"enter 2 numbers to be swapped";
cin>> a>>b;
int temp; //temporary variable for swapping
temp =a;
a=b;
b=temp;
cout<<a<<b;
} // main
Similar questions
Business Studies,
7 months ago
Social Sciences,
7 months ago
History,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago