class Program
{
static void Main(string[] args)
{
int[] arr;
int Even = 0, Odd = 0;
Console.WriteLine("Enter the lenth of the array");
int n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the array Element");
arr = new int[n];
for (int i = 0; i < n; i++)
{
arr[i] = int.Parse(Console.ReadLine());
}
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] % 2 == 0)
{
Even += arr[i];
}
else
{
Odd += arr[i];
}
}
Console.WriteLine("Sume of Even Number {0}", Even);
Console.WriteLine("Sum of Odd Number {0}", Odd);
Console.ReadLine();
}
}
Output:
No comments:
Post a Comment