Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
12
Reply
Errors in Apps Checking Prime Number
Quang Dinh Luong
Oct 6 2015 11:06 PM
443
Reply
This is how my program looks like, sorry for bad arrangement
I get this error: Cannot implicity convert type "string" to "int"
Anyone knows how to fix it? Your help'll be very appriciated
namespace IsThisPrime
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int x = textBox1.Text;
int i = 0;
bool Flag = false;
for (i = 2; i <= x / 2; i++)
{
if ((i == x))
i = i + 1;
if ((x % i == 0))
{
Flag = true;
break;
}
}
if ((Flag == false))
{
// this num is prime number
MessageBox.Show("PRIME");
}
else
{
// this num is not prime number
MessageBox.Show("NOT PRIME");
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
12
)
Next Recommended Forum
error in question submittal
My app search for Prime Numbers work incorrectly