# Example 5

Generate multiplication table of 5 up to 30. But do not print values that are even.

How to check if a number is even?

We know even numbers are those numbers that are divisible by 2. To check a number is divisible by 2 or not we % operator.

If the result of number % 2 expression is 0 then the number is divisible by two, i.e. it is an even number. Otherwise it is not an even number.




 





for (int i = 1; i <= 30; i++)
{
  int answer = 5 * i;
  if (answer % 2 != 0)
  {
    Console.WriteLine("{0} x {1} = {2}", 5, i, answer);
  }
}
1
2
3
4
5
6
7
8
Last Updated: Apr 23, 2020, 10:50 AM