I know how to generate integer random numbers in range [1000-9999].
But, I really don't have idea about how to find, how many of this number are Even and Divisible by 5??
Can someone brilliant help me??
Using C#.Net 2010
Console Application
For every positive and guidelines comment I will like it all.
And for the correct answer I will mark it as a correct answer..
Thank you.. :-)

Pankaj Kumar ChoudharyPosted May 23, 2015, 2:49 AM
int even=0;
int Div_By5=0;
Random Rnd=new Random();
for (int i = 0; i < 200; i++)
{
Rand_Array[i] = Rnd.Next(1000, 9999);
if (Rand_Array[i] >= 1000 && Rand_Array[i] <= 2499)
Num1++;
else if (Rand_Array[i] >= 2500 && Rand_Array[i] <= 4999)
Num2++;
else if (Rand_Array[i] >= 5000 && Rand_Array[i] <= 7499)
Num3++;
else
Num4++;
if (Rand_Array[i] % 2 == 0)
even++;
if (Rand_Array[i] % 5 == 0)
Div_By5++;
Console.WriteLine(Rand_Array[i].ToString());
}
Console.WriteLine("\n" + "Number B/w 1000 and 2499 is={0}", Num1);
Console.WriteLine("\n" + "Number B/w 2500 and 4999 is={0}", Num2);
Console.WriteLine("\n" + "Number B/w 5000 and 7499 is={0}", Num3);
Console.WriteLine("\n" + "Number B/w 7500 and 9999 is={0}", Num4);
Console.WriteLine("Even Number Are {0}", even);
Console.WriteLine("Number Divisible by 5 Are{0} ", Div_By5);
Amex JohnnyPosted May 23, 2015, 4:32 AM
Pankaj Kumar ChoudharyPosted May 23, 2015, 2:52 AM
int even=0;
int Div_By5=0;
Random Rnd=new Random();
for (int i = 0; i < 200; i++)
{
Rand_Array[i] = Rnd.Next(1000, 9999);
if (Rand_Array[i] % 2 == 0)
even++;
if (Rand_Array[i] % 5 == 0)
Div_By5++;
Console.WriteLine(Rand_Array[i].ToString());
}
Console.WriteLine("Even Number Are {0}", even);
Console.WriteLine("Number Divisible by 5 Are {0}", Div_By5);
Console.ReadLine();
Nanhe SiddiquePosted May 23, 2015, 2:49 AM