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 are enumerated types?
what are the 10 different models of writing an addition program in C language?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
Process by which one bit pattern in to another by bit wise operation is?
What is zero based addressing?
What is logical error?
What are the valid places to have keyword “break”?
Why do we use stdio h and conio h?
Do you know the difference between exit() and _exit() function in c?
What is the Purpose of 'extern' keyword in a function declaration?
what will be the output for the following main() { printf("hi" "hello"); }
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
What is masking?
given post order,in order construct the corresponding binary tree
Hi can anyone tell what is a start up code?