Programming Course in C# ¡Free!

Array, even numbers

 Saturday, April 06, 2013 published by Exercises C#
Proposed exercise

Write a C# program to ask the user for 10 integer numbers and display the even ones.

Output



Solution


using System;
public class ArrayEvenNumbers
{
public static void Main()
{   
int[] numbers = new int[10];

for (int i = 0; i < 10;i++)
{
Console.Write("Numero {0}= ",i+1);
numbers[i] = Convert.ToInt32( Console.ReadLine());
}

for (int i = 0;i < 10;i++)
if (numbers[i]%2==0)
Console.Write("{0} ",numbers[i]);
}
}