12,404,895 members (67,285 online)
Rate this:
See more:
```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EvenandOdds
{
class Program
{
static void Main(string[] args)
{
List<double> even = new List<double>();
List<double> odd = new List<double>();

Console.Write("odd: ");
Random randomNums = new Random();

for (int i = 0; i < 25; i++) ;
{

Console.WriteLine();

}

}
}
}```

What do I put in that last `WriteLine` to show the odd numbers?
Posted 31-Oct-11 9:23am
Updated 31-Oct-11 9:27am
v3

Rate this:

## Solution 1

Well, you do not check if the number is odd. To do that do something like :

`bool isOdd = num % 2 != 0;`

Use a local variable there and assign the random number to this local. Then you can easily show it using `Console.WriteLine`. Or access the last item using `list[count - 1]`.
v3
André Kraak 31-Oct-11 15:31pm

my 5, took me to long to find the MSDN % operator link.
Nishant Sivakumar 31-Oct-11 15:32pm

Yeah, MSDN is not easy to search huh? :-)
SAKryukov 31-Oct-11 17:24pm

First, one needs to know what is MSDN... My 5 for the answer.
--SA
Rate this:

## Solution 2

You need to check for odd numbers, which you can do with the % operator[^].
```int Num = 5;

if(Num % 2 == 0)
{
// It's even

}
else
{
// It's odd

}```
Nishant Sivakumar 31-Oct-11 15:33pm

Voted 5 as well. We posted at the same time I guess.
André Kraak 31-Oct-11 15:35pm

Thanks.
Member 8349150 31-Oct-11 15:41pm

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EvenandOdds
{
class Program
{
static void Main(string[] args)
{

int random;

List even = new List();
List odd = new List();

Console.Write("odd: ");
Random randomNums = new Random();

for (int randomm = 0; randomm < 25; randomm++)
{

bool isOdd = randomm % 2 != 0;

Console.WriteLine(odd[randomm].ToString());

}
}

}
}

Does not work too well but I tried what you said
SAKryukov 31-Oct-11 17:25pm

...and you did not explain what's "not too well".
--SA
SAKryukov 31-Oct-11 17:25pm

Sure, a 5.
--SA
André Kraak 31-Oct-11 17:39pm

Thanks.

Top Experts
Last 24hrsThis month
 OriginalGriff 225 Karthik Bangalore 195 Suvendu Shekhar Giri 190 ppolymorphe 175 Richard MacCutchan 172
 OriginalGriff 7,486 ppolymorphe 3,230 Karthik Bangalore 3,227 Richard MacCutchan 2,472 F-ES Sitecore 2,300