I have a query:
Suppose I have the following code:
Code A:
for (int i = 0; i < n + 1; i++)
{
// something here
}
Code B:
int lim = n + 1;
for (int i = 0; i < lim; i++)
{
// something here
}
Which code will be more efficient? Does the conditional expression in Code A gets computed in each iteration of the for loop or does modern compilers take care of it and themselves assign it a constant value?