c# - How to ask the user for 10 numbers and select out of the 10 the numbers that are even -


i new programming, trying ask user 10 numbers in c# , list numbers 10 numbers even. far have done this:

using system; using system.collections.generic; using system.linq; using system.text; //jeyhun mammadov //maximum , minimun numbers  namespace consoleapplication1 {     class program     {         static void main(string[] args)         {             int[] numbs = new int[10];             (int = 0; < 10; i++)                 numbs[i] = convert.toint32(console.readline());              if(numbs[i] % 2 = 0)                 console.readkey();         }     } } 

i don't know next step take, please need 1 this. thanks

you need second loop display numbers, after input user:

for (int = 0; < 10; i++) {      if(numbs[i] % 2 == 0)          console.writeline("{0} even", numbs[i]); } 

also can use linq numbers in 1 statement display them together:

var evennumbers = numbs.where(x => x % 2 == 0);  console.writelines("the numbers are: {0}", string.join(",", evennumbers)); 

if don't know linq migth want read documentation.it might seem complicated first after learn love it.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -