0

Why C++ compiler executes this code very fast? as if it's one statement.

long long sum = 0;
for (long long i = 1; i <= 100000000000; i++)
    sum ++;
cout << sum;

It seems like compilers optimize it as sum += 100000000000. so how? and what's the limitation of this?

seif gamal
  • 59
  • 9

0 Answers0