Given the integer variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another integer variable min. Assume that all the variables have already been declared and that x, y, and z have been assigned values).
.
.
Click on the title for the solution
.
.
if (x < z && x < y)
{
min = x;
}
else if (y < z)
{
min = y;
}
else
{
min = z;
}
.
Click on the title for the solution
.
.
This is the answer:
:
if (x < z && x < y)
{
min = x;
}
else if (y < z)
{
min = y;
}
else
{
min = z;
}
Comments
Post a Comment