What will be printed out as a result of the following code execution?
#include <iostream>

using namespace std;

int main()
{
    int i = 0;

    while(i < 10)
    {
        int i = 10;
        cout<<i<<endl;
        i++;
    }

    return 0;
}
Explanation
int i=0 and int i=10 declarations are located in different scopes. i=10 is relevant inside the loop, and i=0 - outside the loop and for the loop itself.

Следи за CodeGalaxy

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

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