What will the following code print?
#include <iostream>

int main(int i, char * argv[])
{
   while(i = 0, i < 10, i++)
   {
      std::cout << i;
   }
}
Explanation
The while loop condition can be represented as three sequential operations:
i = 0;
i < 10;
i++;
The result of the last operation will be equal to i before the increment, i.e. zero or false, so the loop will not be executed at all.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты