NEED HELP RUNNING MY PROGRAM! let me know if it does what is asked!

Problem:
In this problem you will write a Python program to generate a list of all the the prime numbers between a starting number and an ending number (inclusive).

Problem
Repeatedly ask for inputs until the start and stop numbers are greater than 0.

Enter 2 positive numbers:
-1 1
Enter 2 positive numbers:
0 0
Primes between 0 and 0:
Print out a list of all prime numbers between the starting and stop numbers.

Enter 2 positive numbers: 3 7
Primes between 3 and 7: 3 5 7
Make sure it works regardless of input order.
Enter 2 positive numbers: 7 3
Primes between 3 and 7: 3 5 7
Make sure it works for arbitrary start and stop inputs:

Enter 2 positive numbers: 10 30
Primes between 10 and 30: 11 13 17 19 23 29

MY compiler isn't working right now, can someone please let me know if this program fulfills what is asked, if not whats wrong. Thank you in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
using namespace std;
int main () { 
int X,Y,Primetest;
cout <<" Enter 2 Positive Numbers";
cin >> X >> Y;      
cout << X<<"   "<< Y <<endl; 
bool Prime=true; 
if ( X<0||Y<0)  {  
cout<<" Enter 2 Positive Numbers";
cin >> X >> Y;     
cout << X<<"   "<< Y <<endl; 
if (X<Y) {
cout<<"Primes between " << X <<" and "<< Y<<": "; }
else
if (X>Y) {
cout<<"Primes between " << Y <<" and "<< X<<": ";}
 
if (Primetest>0){  
 
if (X<Y){                   
for( Primetest=X; Primetest<=Y; Primetest++) 
{
Prime = true;
for(int factor=2; factor<Primetest-1; factor++)  
{
if(Primetest%factor == 0) 
{                          
Prime = false;
break;
}
}
}
}
}
}
}
You've written your program in C++ when the question asked for it to be written in python...
As long as you have internet, there is always ideone.com. But from the code, here a few pointers:

- Line 19 is checking if Primetest is greater than 0 when Primetest was never initialised to a value.

- Line 9 should be replaced by a while loop

- You set the variable Prime to true or false, but it is never used in the computation

- There is no print out of the primes
Topic archived. No new replies allowed.