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

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes