Answer to Question #348831 in C++ for Sasi

Question #348831

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



1
Expert's answer
2022-06-07T17:44:10-0400
#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; 
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS