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
Explain #pragma statements.
What are register variables? What are the advantage of using register variables?
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
What is adt in c programming?
Why doesnt long int work?
What is call by reference in functions?
Can a variable be both constant and volatile?
What is the function of volatile in c language?
Which is best book for data structures in c?
What is the condition that is applied with ?: Operator?
write a programming in c to find the sum of all elements in an array through function.
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
Explain how do you list files in a directory?
What is a rvalue?
Explain how can I convert a number to a string?