string strLine;//not constant int index = 0; while(index < strLine.length()){//strLine is not modified};
how many times strLine.length() is evaluated
do we need to put use nLength with nLength assigned to strLine.length() just before loop
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.
lengthwill be evaluated every time you go via the loop, however sincelengthis constant time (O(1)) it doesn’t make much difference and adding a variable for storing this value will probably have a negligible effect with a small hit on code readability (as well as breaking the code if the string is ever changed).