Question: 2 Increment & Decrement Find The Bugs! The following code is intended to increment / decrement A and B until A is equal to X

2
Increment & Decrement Find The Bugs!
The following code is intended to increment / decrement A and B until A is equal to X and B is equal to Y. Find the bugs!
publicstaticvoidMakeTheNumbersMatch(int a, int b, int x, int y)
{
while (a != x && b != y)
{
if (a > x)
{
a++;
}
else
{
a--;
}
if (b > y)
{
b++;
}
else
{
b--;
}
}
}
 2 Increment & Decrement Find The Bugs! The following code is

2. Increment &Decrement -Find The Bugs The following code is intended to increment/decrement A and B until A is equal to X and B is equal to Y. Find the bugs! publicstaticvoidMakeTheNumbers Match(int a, int b, int x, int y) while (ax && b!-y) if (a>x) att else if (b> y) else

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!