Please visit DEMANDDRAFT.SHOP for quality of products...

Ad

Search This Blog

Sunday, June 10, 2012

Write a Program Given Number is Prime Number or Not?


 protected void CheckGivenNumerIsPrimeOrNot()
 {
  intnumber = Convert.ToInt32(textBox1.Text);
  inti;
  for(i = 2; i < number; i++)
  {
   if(number % i == 0)
   {
     MessageBox.Show("Number is  not a prime");
     break;
   }
  }
  if(i==number)
  {
     MessageBox.Show("Number is  a prime");
  }
}

No comments:

Post a Comment