I am attempting to understand what a friend coded for me. I was supposed to get 3 int values and output them in order from lowest to highest. I got zero points for this. (I missed the part where I was not allowed to use nested if else statements) However, my instructor also told me that my logic was not sound. My friend insists this will work, but I am mostly confused with why he assigns the variables like this below:
numberTemp = numberOne;
numberOne = numberTwo;
numberTwo = numberTemp;
I am mostly confused with why he assigns the variables like this below:
numberTemp = numberOne;
numberOne = numberTwo;
numberTwo = numberTemp;
1. Put the value from numberOne into a temporary variable, numberTemp, so that you can overwrite numberOne while keeping the value.
2. Overwrite numberOne with numberTwo's value.
3. Overwrite numberTwo with numberOne's original value, found in numberTemp.
My friend insists this will work, but I am mostly confused with why he assigns the variables like this below:
Why don't you ask him/her?
Have you compile it? What errors are you getting?
Does the program work like it should? Based on the instructor's comments, most likely not.
I agree with the instructor, the logic does not make sense.
As kemort mentioned, I would recommend you do the coding. then comeback here with any issues that you may have.