Having the user enter in two numbers and generate even numbers between those numbers. In my code here, when it performs, I usualy get two extra numbers. For instance user enters 0 and 10
what I will get is 0, 2, 4, 6, 8, 10,12
I know my number++ is incorrect. im thinking of adding two to it but don't know how. Anyone out here?
int _tmain(int argc, _TCHAR* argv[])
{
//Declare a number the user will enter
int number1;
int number2;
int even;
int odd;
//Tell user to enter a number
cout<<"\n\tEnter in two numbers: ";
cin>>number1;
cout<< " " ;
cin>>number2;
//whle loop
if (number2<number1)
{
cout<<"number 2 will now be ";
number2=number1;
number1=number2;
cout<<number2;
}
//Declare a counter to calculate even number
int counter;
counter=0;
cout<<"even: ";
while (number1<=number2)
{
if(number1%2==0)
{
even=number1+2;
cout <<even << " " ;
}
number1++;
}