Hi again! I've got a new problem which is, create a program that will ask for three inputs, x,y&z. Once these numbers have been given...display allo numbers from x to y with increments of z. (Use while loops)
Sample Program Output, it should be like this(the x,y,z and underscores under the numbers are not included, just to represent what the number is):
Enter x: 4
Enter y: 18
Enter z: 2
4 6 8 10_12_ 14 16 18
x z z y
//Determine whether going up or down
if(x < y)
{
int i = x;
std::cout << x << " ";
while (i + z < y)
{
i += z;
std::cout << i << " ";
}
std::cout << y;
}
if(x > y)
{
int i = x;
std::cout << x << " ";
while (i + z > y)
{
i += z;
std::cout << i << " ";
}
std::cout << y;
}
Pretty sure this can be done without using the ugly 2 if statements especially since the only difference is one uses > while the other uses <.
You didn't specify whether z is given as negative for going down. This assumes it is. Zero error checking is done. Also didn't handle case where x=y.