Answer to Question #256574 in C# for shaves

Question #256574

Write a Program in C# which take two dimension jagged integer array from user, after that display number in the form of Odd and Even from whole array?


1
Expert's answer
2021-10-25T14:49:45-0400
using System;
using System.Collections.Generic;


namespace App
{






    class Program
    {


        static void Main(string[] args)
        {


           int [][]numbers=new int[4][];


            for(int i=0;i<4;i++){
                numbers[i] = new int[4];
                for(int j=0;j<4;j++){
                    Console.Write("Enter number [{0}][{1}]: ",i,j);
                    numbers[i][j] = int.Parse(Console.ReadLine());        
                }
            }


            Console.WriteLine("All even numbers: ");
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (numbers[i][j] % 2 == 0) {
                        Console.Write("{0} ", numbers[i][j]);
                    }
                }
            }


            Console.WriteLine();
            Console.WriteLine("All odd numbers: ");
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (numbers[i][j] % 2 != 0)
                    {
                        Console.Write("{0} ", numbers[i][j]);
                    }
                }
            }
            


            
            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
APPROVED BY CLIENTS