Im trying to take all prime numbers 1 to 100 and outputting them to a file but its not working here is my code so far.

#include <iostream>
#include <fstream>
using namespace std;

bool isPrime(int numcheck);
void write_prime(int prime, ofstream &outfile);

int main()
{
	ofstream primefile("prime.txt");
	
	for (int ntc = 2; ntc = 100; ntc++)
	{
		if(isPrime(ntc))
			write_prime(ntc, primefile);
	}
	primefile.close();
	return 0;
}

bool isPrime(int numcheck)
{
	for (int x = 2; x < numcheck; x++)
	{	
		if(numcheck % x == 0)
		{
			return false;
			break;
		}

	}
	return true;
}

void write_prime(int prime, ofstream &primefile)
{
	primefile << prime << "\n";

}

nevermind i figured it out

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.