Create a class Zero, write a function called zero_small) that has two integer arguments being passed by reference and sets the smaller of the two numbers to 0.
Runtime input:
23
6
Output:
23
#include <iostream>
using namespace std;
class Zero
{
public:
void zero_small(int& a, int& b)
{
if (a < b)
{
a = 0;
}
else
{
b = 0;
}
}
};
int main( )
{
int x, y = 0;
cin >> x;
cin >> y;
Zero z;
z.zero_small(x, y);
cout << x << "\n";
cout << y;
return 0;
}
Comments
Leave a comment