A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

Discussion Forum

Que. Consider the following three C functions :

[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?
a. Only P3
b. Only P1 and P3
c. Only P1 and P2
d. P1, P2 and P3
Answer:Only P1 and P2
Confused About the Answer? Ask for Details Here
Know Explanation? Add it Here

Similar Questions: