Consider the below code snippet:
for(i=0;i<10;i+=2) // 1
for(i=0;i<2;i=i+2) // 2
Which one will be better to use?
Does it make any difference in the performance?
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.
There is no definite answer to your question. It depends on how smart your compiler is among other things (optimization level, …) and on the target platform. This is not a C language question. The language is not more or less performant by itself. It just depends on what the compiler builds out of it. So test it for your use case if performance matters at all…
Otherwise my advice, just write it in the way you feel it more readable.