Why does it say there isn't any if before the else command?
Tried it several times.
btw, this is a program designed to show all the numbers from 1-1000 that can be divided by 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
int main()
{
int a;
a=1;
while(a<=1000);
if(a%2==0);
cout<<a;
a++;
else
a++;
return 0;
}
cout<<a; is not part of the if statement because of the semicolon at the end of the previous line. if(a%2==0); means if a is an even number do nothing.