C# Program to Count Even and Odd Numbers in Array – C# Programming Example
Arrays C# Console For Loop If Else Statement

C# Program to Count Even and Odd Numbers in Array

Write a C# program to input elements in array from user and count even and odd elements in array.

How to find total number of even and odd elements in a given array using C# programming. Logic to count even and odd elements in array using loops.

 

Step by step descriptive logic to count total even and odd elements in array.

  • Input size and elements in array from user. Store it in some variable say size and arr.
  • Declare and initialize two variables with zero to store even and odd count.
  • Iterate through each array element. Run a loop from 0 to size – 1. Loop structure should look like for(i=0; i<size; i++).
  • Inside loop increment even count by 1 if current array element is even. Otherwise increment the odd count.

C# Code: 

Code Output:

C-sharp program to count even and odd elements in array

C# program to count even and odd elements in array

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: