Ahmet Taha

Ahmet Taha

  • NA
  • 381
  • 20.5k

displaying even and odd number

Oct 15 2021 8:03 AM

Hello Guyz coiudl anyone help me? the output should be like this

Enter Number : 10

The even number is : 2 4 6 8 10

The Odd number is 3 5 7 9

here is my code:

int x;
Console.Write("Input Number:\t");
int num = Convert.ToInt32(Console.ReadLine());
for (x = 0; x < num; x++)
{
    if (x % 2 == 0)
    {
        Console.Write(" ");

    }
    else
    {

        //Console.Write("\n");
        Console.Write("{0}", x);
    }
}

Answers (5)