Question: Complete in C++ The function swap should take two integers and swap their values, returning true if the numbers are equal to each other, and
Complete in C++
The function swap should take two integers and swap their values, returning true if the numbers are equal to each other, and false otherwise.
The main function provided here will test your function by accepting 3 integers as input and swapping them around a bit.
Output will depend entirely on what you choose for input, but here is an example
Input
3 7 3
Output
0
7 3
1
3 3
The 0 represents "false", because 3 and 7 are not equal.
7 3 is then printed, because the values have been swapped.
1 is then printed, because 3 and 3 are equal
and then 3 3 to represent the swapped values
Starter code is listed bellow complete in C++ code
#include
//Do not change the code thats in main!!!
int main() {
int a, b, c;
std::cin >> a >> b >> c;
std::cout << swap(a, b) << std::endl;
std::cout << a << " " << b << std::endl;
std::cout << swap(b, c) << std::endl;
std::cout << b << " " << c << std::endl;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
