Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

GATE | GATE-CS-2001 | Question 43

  • Last Updated : 28 Jun, 2021

Consider the following three C functions :

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.




[PI] int * g (void
  int x= 10; 
  return (&x); 
}  
     
[P2] int * g (void
  int * px; 
  *px= 10; 
  return px; 
     
[P3] int *g (void
  int *px; 
  px = (int *) malloc (sizeof(int)); 
  *px= 10; 
  return px; 
}

Which of the above three functions are likely to cause problems with pointers? (GATE 2001)
(A)
(B)
(C)
(D)

(A) Only P3
(B) Only P1 and P3
(C) Only P1 and P2

(D) P1, P2 and P3


Answer: (C)

Explanation: See https://www.geeksforgeeks.org/c-dynamic-memory-allocation-question-2/

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :