Mar 4, 2012 at 3:33pm UTC
#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;
}
Mar 4, 2012 at 4:04pm UTC
Stuck on the if statement and the loop
Mar 4, 2012 at 4:06pm UTC
loop through all numbers between the lower number and the bigger number.
- if prime, output it
- if not prime, don't
Mar 4, 2012 at 4:23pm UTC
#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 Mar 5, 2012 at 3:27pm UTC
Mar 4, 2012 at 4:25pm UTC
return ?
That's wrong. it should be return ;
Was that your question?
Mar 5, 2012 at 3:42pm UTC
This code i ave still cant get it working
Mar 7, 2012 at 12:15am UTC
Can someone give me a hand with my loop in this code
Mar 8, 2012 at 4:36am UTC
Your brackets are all over the place dude.
Mar 8, 2012 at 5:04am UTC
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.