What will be the output of the following C++ function?

int main()
   {
       register int i = 1;
       int *ptr = &i;
       cout << *ptr;
   return 0;
   }

a) 0
b) 1
c) Compiler error may be possible
d) Runtime error may be possible

1 thought on “What will be the output of the following C++ function?”

  1. c
    Explanation: Using & on a register variable may be invalid, since the compiler may store the variable in a register, and finding the address of it is illegal.

Leave a Comment