Display all the prime numbers between 2 numbers

#include <iostream>
#include <ctime>
#include <cmath>

void primeNumbers (int num1, int num2){
//find the prime numbers between num1 and num2

if statements or a loop

//display the numbers
return?
}
int main () {

primeNumber(5,10);
system ("pause")
return 0;

}

What's your question?
Stuck on the if statement and the loop
loop through all numbers between the lower number and the bigger number.
- if prime, output it
- if not prime, don't
#include <iostream>
#include <ctime>
#include <cmath>

void primeNumbers (int num1, int num2){
//find the prime numbers between num1 and num2

{
for (int i=2; i<100; i++)
for (int j=2; j<i; j++)
{
if (i % j == 0)
break;
else if (i == j+1);
cout << i << " ";


//display the numbers
return;
}
int main () {

primeNumber(5,10);
system ("pause")
return 0;
Last edited on
return?
That's wrong. it should be return;

Was that your question?
This code i ave still cant get it working
Can someone give me a hand with my loop in this code
Your brackets are all over the place dude.
This thread is just like this one:
http://www.cplusplus.com/forum/beginner/63859/

Maybe that'll help you out a bit....
Yes except that question was asked properly. Ken777, it is extremely offensive to the helpers of this forum if you just copy paste a code straight from your homework sheet and make no attempt to structure your question. The forum rules are clear on this note. If you had followed the guidelines you probably would have a working program right now.
Topic archived. No new replies allowed.