13,043,491 members (52,214 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<double> even = new List<double>();
List<double> odd = new List<double>();

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 145 ppolymorphe 105 Sheila Pontes 95 Richard MacCutchan 95 LuxGiammi 80
 OriginalGriff 4,295 RickZeeland 1,834 ppolymorphe 1,559 F-ES Sitecore 1,483 Dave Kreskowiak 1,309