Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 440 Bytes

CodesAndAnswers.md

File metadata and controls

17 lines (15 loc) · 440 Bytes

"Guess the output of given codes" type questions

  1. What will be output of following code?
int * f(){
    int a = 10;
    int *b = &a;
    return b;
}

main(){
    int *temp = f();
    cout<<*temp<<endl;
    return 0;
}

Answer: Either 0 or garbage value, as it will be a dangling pointer.