Answer to Question #294395 in C# for ITSyndicate

Question #294395

In C#, please.

Create a program that will accept inputs into 5x5 25-element two-dimensional

integer array Count2D5x5Array. Your program should count the odd and even numbers

that appeared in the list of accepted values.


1
Expert's answer
2022-02-06T03:51:59-0500


using System;
using System.Collections.Generic;
using System.Globalization;


namespace App
{


    class Program
    {
        static void Main(string[] args)
        {
            int[,] Count2D5x5Array = new int[5, 5];




            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Console.Write("Enter the value [{0},{1}]: ", i, j);
                    Count2D5x5Array[i, j] = int.Parse(Console.ReadLine());
                }
            }
            int oddNumbers=0;
            int evenNumbers=0;
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if(Count2D5x5Array[i, j]%2==0){
                        evenNumbers++;
                    }else{
                        oddNumbers++;
                    }
                }
            }


            Console.WriteLine("The odd numbers that appeared in the list: {0}", oddNumbers);
            Console.WriteLine("The even numbers that appeared in the list: {0}", evenNumbers);






            Console.ReadLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS