I would like to write something like this but I am not sure how.
for(int i = 0; i < ( the greater value between intA and intB ); i++)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The expression in the middle of your
forstatement works exactly like anyifstatement; the loop only continues when the expression evaluates as true. So there are a few logically equivalent ways to write what you want:But in your specific case, none of these are ideal since the first two aren’t really clear code and they all evaluate
intAvsintBon each iteration through the loop. What’s even better is something like: