What is wrong with my program?

This is what i am trying to do
ask the user for a single-digit positive even number w.
Then read w from the user. If w is not legal, the program repeatedly makes the user type in another value until a legal value of w has been entered. (This part may be a while loop.)

#include <iostream>
using namespace std;

int main ()
int w;
cout << "enter positive even single digit: ";
cin >> w;
for ( w < 10 && w % 2 == 0 ) {
cout << w;
if ( w > 10 )
cout << "illegal";
return 0;

I tried compiling and it keeps telling me i have ; errors and ) errors but i went over it like 10 times and cant figure out my errors or if i wrote the program to output what i am looking for
Please put your code in code tags to make it easier to read.
Your for loop is incorrect.
Replace for with while and it will probably work.
delete cin>>w
replace cout<<w with cin>>w
illegality would also apply to evenness
Is that for loop meant to be a while? For loops must have three expressions inside of the parentheses, but you only have a loop condition.
Topic archived. No new replies allowed.