//this program needs to print even numbers form 2 - 10
#include <iostream>
using namespace std;
int main()
{
int count;
int x = 0;
while (x!=10)//(x!=12)
//I used 10 instead of 12 and it works fine but it
//needs to use 12 instead 10
{
x = x + 2;
cout << x << "\n""\n";
count++;
cout << endl;
}
return 0;
}
That code works ONLY for constant values,what IF the user were to supply the values and an odd number(value) were inputted?then you'll have to optimize your code farther
//include everything that starts your source code blah blah
cin>>count_to;
for(int n=0;n<=count_to;n++)
{
if (n%2==0)
cout<<n;
}
/*you input the rest of the codes here
tada */