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 a built-in function in C?
What is the difference between union and anonymous union?
What is break in c?
What are the 4 types of unions?
How #define works?
What is formal argument?
What is the use of volatile?
What are unions in c?
What is the correct code to have following output in c using nested for loop?
Are local variables initialized to zero by default in c?
Explain how can a program be made to print the name of a source file where an error occurs?
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?
What is a constant?
What is scope and lifetime of a variable in c?
What does c mean in standard form?