πŸ“Š C Programming
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.
πŸ’¬ Discuss
βœ… Correct Answer: (D) The program may crash.

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
181
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Manisha Agrawal
Publisher
πŸ“ˆ
83%
Success Rate