cout<< "Hello, please enter a whole number that will be the starting number. \n" <<endl;
cin>>x;
cout<< "Please enter a whole number that will be the ending number. \n" <<endl;
cin>>y;
for ( ; x<y; x+=4) //counts in multiples of 4
{
cout<<"\n"<< x << "\n"; //displays the multiples
}
if(x>=y) //ends at the ending variable
{
cout<<y; //need to figure out how to get it to stop before y if y isn't a multiple of 4
}
How would I be able to get the end number to not show if it is not a multiple of 4, but show if it is a multiple of 4?
Only numbers which end in 4 or 8 *have end numbers which are multiples of 4. You want n = 4 and then to output n and then n + 4 = n (which is 8) and then n = n + 16 (which is 24) and then n = n + 4 (28), n = n + 16 (44) etc...
OP's question is pretty straight-forward. He even gave examples.
First, don't use floats -- they'll goof up. Use integers (int or unsigned or something like that).
Second, your basic loop continues while x < y, meaning that it does NOT continue even if x == y. To change the end condition, change the comparison to include equality: