Prime Number C++
Just now, Kagami Tsukino said:I try adding bunch of bracket and I still do not get it. still having same problem.
void primeNumber(int num)
{
ofstream primeNumbersInput;
primeNumbersInput.open("user_number_input.txt");for (int i = 2; i < num; i++)
{
for (int j = 2; j < i; j++)
{
if (i % j == 0)
{
break;
}
else if (i == j + 1)
{
cout << i << " " << endl;
}
primeNumbersInput << i << endl;
}
}
primeNumbersInput.close();
}
Well....you only needed to put one set of brackets in there.
Another Hint: look at your nested for loop, something is misplaced by a single line which is causing all the issues.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now