I'm trying to do an exercise where in a range of 0-30 I want to know which numbers are divisible by 3 or 4. Working with a if
for each situation works. But if I try to use the logical operator ||
does not work. It is part of the code that is commented on.
private void button5_Click(object sender, EventArgs e)
{
int iA;
for (iA = 0; iA <= 30; iA++)
{
//if (iA % 3 == 0 || iA % 4 == 0);
//{
// MessageBox.Show(iA + " é múltiplo de 3 ou de 4");
//}
if (iA % 3 == 0)
{
MessageBox.Show(iA + " é múltiplo de 3");
}
else if (iA % 4 == 0)
{
MessageBox.Show(iA + " é múltiplo de 4");
}
}
}