A

Admin • 833K Points
Coach

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.
  • Correct Answer - Option(D)
  • Views: 17
  • Filed under category C Programming
  • Hashtags:

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.