answersLogoWhite

0

First10 prime number program

User Avatar

Anonymous

16y ago
Updated: 10/17/2024

Not tested:

void printPrimes(int n) {

int a = 0, b = 0;

float c = 0.0f;

bool isp = true;

int primes = 0;

while(true) {

a++;

do {

b++;

if(b > 1) {

c = (float)a/(float)b;

if(c = (int)c)

if(b != a) {

isp = false;

break;

}

else

isp=true;

}

} while(b<a);

if(isp) {

primes++;

std::cout << a << endl;

}

if(primes > n)

break;

b = 0;

c = 0;

isp = true;

}

}

void main() {

printPrimes(10);

}

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra

Add your answer:

Earn +20 pts
Q: First10 prime number program
Write your answer...
Submit
Still have questions?
magnify glass
imp