print first n prime no

Omniitstudent
Posted by Omniitstudent under C# category on | Points: 40 | Views : 1612
=========================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication25
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("input the number");
int nNum1 = Convert.ToInt32(Console.ReadLine());
int nA = 1, nC = 2;

while (nA<=nNum1)
{
int flag = 1;
for (int i=2;i<nC; i++)
{
if (nC % 2== 0)
{
flag = 0;

}
}

if (flag!=0)
{
Console.WriteLine(nC);
nA++;

}

nC++;
}
Console.ReadLine();
}
}
}
//===========================================================================================
//// output--5
// 2
// 3
// 5
// 7
// 9

=======================

Comments or Responses

Posted by: T.Saravanan on: 2/20/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Kindly post your code inside the code tag.

Login to post response