Answer to Question #348829 in C++ for Karthi

Question #348829

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-08T14:27:09-0400
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