I am not sure what I am doing wrong here. Any help would be greatly appreciated.
The problem I'm trying to do is:
Write a program that receives two numbers less than 1000 from the user and switches the value of those two numbers. Then, output the values in the following format.
X = 6 Y = 19
--------------------------------------------------------------------------------
X = 19 Y = 6
The X and Y are vertically aligned to the second X and Y. The dash of lines is the width of the default terminal window
1 2 3 4 5 6 7 8 9
int firstNumber, secondNumber, a, b;
cout << "Enter two numbers in the format (_ _) that range from ""0 to 1000 \n";
cin >> firstNumber, secondNumber;
cout << firstNumber << secondNumber << " \n";
cout << "-------------------------------------------------------------- \n";
firstNumber = a;
secondNumber = b;
cout << b, a;
The comma operator is rarely used and not for what you do on lines 4 and 9.
How can you do output on line 5 syntactically right, but not on line 9?
If you correct the line 4 and the user writes 6 and 19
then the line 5 prints:
619
Perhaps you want to add the "X =" and "Y =" in there too?
While your code (once corrected) does change the order that the values do print, is it possible that you should actually swap the values that variables firstNumber and secondNumber do have?
Thank you very much for your time,
I will go ahead and make those changes but I felt something was wrong.
I'm pretty sure I'm supposed to actually swap the values of those variables.
Any advice as far as making the values actually swap rather than doing what I did?