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?
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();
}
}
}
Comments
Leave a comment