Code to display prime numbers between 1 to 100?

Kmandapalli
Posted by Kmandapalli under C# category on | Points: 40 | Views : 942
static void Main(string[] args)
{
bool isPrime = true;
Console.WriteLine("Prime Numbers : ");
for (int i = 2; i <= 100; i++)
{
for (int j = 2; j <= 100; j++)
{
if (i != j && i % j == 0)
{
isPrime = false;
break;
}
}
if (isPrime)
{
Console.Write("\t" +i);
}
isPrime = true;
}
Console.ReadKey();
}

Comments or Responses

Login to post response