Write program to find odd even number c#

using System;

namespace FindOddEvenNumbers
{
  class Program
  {
    static void Main(string[] args)
    {
      // Create a list of numbers
      int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

      // Initialize two lists to store odd and even numbers
      int[] oddNumbers = new int[numbers.Length];
      int[] evenNumbers = new int[numbers.Length];

      // Iterate through the list of numbers
      for (int i = 0; i < numbers.Length; i++)
      {
        // Check if the number is even
        if (numbers[i] % 2 == 0)
        {
          // Add the number to the list of even numbers
          evenNumbers[i] = numbers[i];
        }
        else
        {
          // Add the number to the list of odd numbers
          oddNumbers[i] = numbers[i];
        }
      }

      // Print the list of odd numbers
      Console.WriteLine("Odd numbers:");
      for (int i = 0; i < oddNumbers.Length; i++)
      {
        Console.WriteLine(oddNumbers[i]);
      }

      // Print the list of even numbers
      Console.WriteLine("Even numbers:");
      for (int i = 0; i < evenNumbers.Length; i++)
      {
        Console.WriteLine(evenNumbers[i]);
      }
    }
  }
}
Write program to find odd even number c# Write program to find odd even number c# Reviewed by Bhaumik Patel on 9:14 PM Rating: 5