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


Please Help Members By Posting Answers For Below Questions

What is the advantage of c?

611


Explain setjmp()?

657


What is clrscr ()?

637


Why main function is special give two reasons?

948


What is keyword with example?

641






Are local variables initialized to zero by default in c?

549


How can I access an I o board directly?

623


What is c token?

609


What is FIFO?

676


What are two dimensional arrays alternatively called as?

661


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

740


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2236


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

813


What are dangling pointers in c?

641


Find MAXIMUM of three distinct integers using a single C statement

624