A while loop problem

I'm new here i just started C++ about two weeks ago, so im still a beginner here. I need help from anyone of u guys to detect any errors. I wrote a "while loop" to determine a total even numbers of a range but it cant work.







#include<iostream>

using namespace std;

int main()
{
int range;
int cnt=1,even=0;
cout<<"Please enter the range number:"<<endl;
cin>>range;
if(range>=0 && range<=200)
while(cnt<=range)
{ if((cnt%2)==0)
even++;
cnt++;}
system("PAUSE");
return 0;
}

Last edited on
add
 
cout << even << endl;


before system("pause") and after the while loop
wow careless mistake there , thx man!
Why did you decide that it does not work? You should insert a statement before the call of system to output the value of even that to know the result.
Last edited on
lol, i didnt notice it, really a careless mistake... sry about that
Topic archived. No new replies allowed.