This is in reference to C++ programming.
Update:I really don't understand it either, its a question on a final exam for a Programming I class in C++ and that is the exact wording of it, copied and pasted here. My feeling is that it has something to do with pre-testing conditions on a some kind of loop. Maybe a For, If, or While pre or post condition check. Must be some programmers out there that can give me a clue here, a little nudge in the right direction would even be appreciated. Thanks.
Copyright © 2024 1QUIZZ.COM - All rights reserved.
Answers & Comments
Verified answer
it is a good practice because it does not confuse the programmer between an assignment operator '=' and a comparison operator '=='.
as opposed to if (num == 5)?
One reason is that you might accidentally type "if (num = 5)" in which case, the number 5 gets placed into the variable, num. You can't screw it up when you say "if(5 == num)" because if you accidentally type "if (5 = num)" you'll get a compiler error.
But who knows. The person asking the question may have something else in mind. It would be helpful if you gave a bit more detail.
I agree with Macgee, but I say it is BAD practice!
If a programmer cannot make the difference between "=" and "=="... he/she is NOT a programmer.
You need to provide more information. This is quite possibly the most ambiguous question I have ever read.