I need to display odd/even for each number inserted in Console Application C#

  • Thread starter Thread starter keeponfalling
  • Start date Start date
K

keeponfalling

Guest
Hello all,

If you can please help me, I'm new to see sharp programming.

I need to display odd/even for each digit from a number like this:

4444
even
even
even
even

So, I extract each digit from the right - to the left (it was easy for me like this) and I have this code:

static void Main(string[] args)
{

string inputData = Console.ReadLine(); // the digit
int number = Convert.ToInt32(inputData);

int aDigit = number % 10000 / 1000;
int bDigit = (number % 1000) / 100;
int cDigit = (number % 10);
int dDigit = (number % 100) / 10;
}


To get odd/even from each digit I use the concatenate method, and combine each digit with the string name odd/even and in console I get eveneveneveneven (for 4444). Is there a way to get like a block or list with concatenate method.

Or is there with if/else function and display the odd/even result with if (aDigit %2 ==0). and return in console writeline even/odd like a list.

Thank you for your time.

Continue reading...
 
Back
Top