M

Manisha Agrawal • 9.34K Points
Tutor III

Q. What is the output of the following code snippet?

Code:
#include <stdio.h>
#include<stdlib.h>
void set(int *to) {
    to = (int*)malloc(5 * sizeof(int));
}
void solve() {
    int *ptr;
    set(ptr);
    *ptr = 10;
    printf("%d", *ptr);
}
int main() {
    solve();
	return 0;
}
  • (A) 10
  • (B) Garbage Value
  • (C) Cannot Say
  • (D) The program may crash.

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics