Find all Prime numbers in a range

Im trying to create a program that lists all prime numbers within a range of two number. Can someone please let me know why the below program isn't working?

#include <iostream>
using namespace std;

int main(){

int high_range;
int low_range;
int w;

cout <<"Input highrange here: ";
cin >> high_range;
cout <<"Input lowrange here: ";
cin >> low_range;

for(w=low_range; w>=high_range; w++)
if(w%2!=0 && w%3!=0 && w%4!=0 && w%5!=0 && w%6!=0 && w%7!=0 && w%8!=0 && w%9!=0)
cout << w;

return 0;
w>=high_range; w++) should be w<=high_range; w++)
you are correct. thanks for your help.
But I think your code does not work properly. You need to implement a function that checks first whether the number is prime or not then print it out.
Topic archived. No new replies allowed.