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
Can we assign integer value to char in c?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
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 you please explain the difference between malloc() and calloc() function?
What is an arrays?
Are comments included during the compilation stage and placed in the EXE file as well?
What is indirection in c?
Explain logical errors? Compare with syntax errors.
Explain what happens if you free a pointer twice?
What is the use of function in c?
How can you increase the allowable number of simultaneously open files?
Is that possible to add pointers to each other?
What are enumerated types?
Why isn't any of this standardized in c? Any real program has to do some of these things.
What are all different types of pointers in c?