What will be printed out as a result of the following code execution?

#include "stdio.h"

int main() {
    int * var = new int(2);
    *var*=2;
    printf("%d", *var);
    return 0;
}
Explanation
Pointers are used here, var is a pointer to an integer that is accessed with *var. In the first line *var is initialized with 2. Second line is equal to *var = (*var) * 2

Следи за CodeGalaxy

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

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