Do not write such code. This is a speed code that someone will once read and set off Whoa! and lose 5 minutes of his life, trying to understand why you did it. Within 5 minutes he will never return, you will be obliged to him for a good reason.
If squeezing the result volume is really important, use an extra set of curly braces:
{
long result = 1;
for (int loop = 0; loop <= 10; loop++)
{
cout << "2^" << loop << "=" << result << endl;
result *= 2;
}
}
, , :
void printPowersOfTwo(int from, int to)