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
What is the c value paradox and how is it explained?
How can I pad a string to a known length?
while initialization of array why we use a[][2] why not a[2][]...?
Where static variables are stored in c?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
Do pointers need to be initialized?
What is a pointer in c plus plus?
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
Explain how do you search data in a data file using random access method?
What are the scope of static variables?
pierrot's divisor program using c or c++ code
How to throw some light on the b tree?
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
Can a pointer point to null?
Does c have circular shift operators?