How to count the total odd numbers in array in C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        int[] arr = { 2, 6, 0, 9, 1, 8, 5 };
        
        var evenNums = arr.Count(n => n % 2 != 0);

        Console.WriteLine(evenNums);
    }
}




/*
run:

3

*/

 



answered Nov 1, 2020 by avibootz
...