>>
|
No. 749
Kind of late, but I may be helping somebody with this.
As far as I can tell, you're only required to take two numbers and print those two numbers. Your program is not only changing the values of the two numbers, but is using a loop to do so repeatedly, which is not only unnecessary but problematic, even dangerous if working with important data.
I'm not going to point out the problems with the loop because a loop is entirely unnecessary. The task can be done with just the two integers and a control statement.
int main()
{
int x=0, y=0;
/*
cout << "Enter two numbers: ";
Giving prompts to the user is a good idea if you want other people to know how to use your program.
*/
cin >> x >> y;
if(x > y)
cout << x << '\n' << y << endl;
else
cout << y << '\n' << x << endl;
}
The program either prints x then y, or y then x. You DO NOT change the numbers for a simple printing job. If you wanted to swap the values of x and y for the sake of one cout statement, then you would need to change x and y, but to do that without a third dummy variable is a test I'll leave for you.
|