Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write the program for prime numbers?

Answer Posted / azka sumbel

namespace prime_381
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int a;
int result;
int i, j;

private void button1_Click(object sender, EventArgs
e)
{

a = Convert.ToInt32(textBox1.Text);
prime();
textBox1.Clear();
textBox1.Focus();

}
int flag;
public void prime()
{
flag = 1;

for (i = 2; i <= a / 2; i++)
{
if (a % i == 0)
flag = 0;
}
if (flag == 1)
MessageBox.Show("Prime.");
else
MessageBox.Show("not Prime");
}
}
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a built-in function in C?

1513


What is the difference between union and anonymous union?

1249


What is break in c?

984


What are the 4 types of unions?

988


How #define works?

1049


What is formal argument?

1092


What is the use of volatile?

1043


What are unions in c?

980


What is the correct code to have following output in c using nested for loop?

1027


Are local variables initialized to zero by default in c?

984


Explain how can a program be made to print the name of a source file where an error occurs?

1134


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

1047


What is a constant?

995


What is scope and lifetime of a variable in c?

989


What does c mean in standard form?

1101