Search This Blog

Tuesday, 9 June 2015

A program to find whether a given number is prime or not using c#

using System;
class Program
{
static void Main(string[]args)
{
int i;
Console.WriteLine("enter any number");
int a = int.Parse(Console.ReadLine());
for(i=2;i<a;i++)
{
  if(a%i==0)
  break;
}
if(a==1||i==a)
Console.WriteLine("the number is prime");
else
Console.WriteLine("the number is not pirme");
Console.Read(); 
}
}


OUTPUT



CLICK TO DOWNLOAD




No comments:

Post a Comment