Monday, 3 August 2015

PRIME NUMBER BETWEEN 1 TO 100 IN CONSOLE APPLICATION

PRIME NUMBER BETWEEN 1 TO 100 IN CONSOLE APPLICATION
1.       1 Step – Take/Add a Console Application in Visual Studio.


1    2        Write The Code For The Prime Numbers Between 1 To 100.


2    3       Code…..
//……………………………………………………………………..//
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();   
        }
//……………………………………………………………………………………………………………………………………………………………………//

 4-Source Code (Image-1)


5- Output (Image-2)


6- Enjoy the Program





3 comments:

Factorial of a Number

Recently Viewed