| | | | Question Answer Tutorial - Linux->Memory | | | | Question: What is the output of this program?
#include #include #include int main() { int ptr; ptr = (int)malloc(sizeof(int)*10); return 0; } | | Answer: None of the mentioned options
| | | | | | | | Question: What is the output of this program?
#include #include struct st{ int a; char b; }; int main() { struct st *st_ptr; st_ptr = malloc(sizeof(struct st)); printf("%d ",sizeof(struct st)); return 0; } | | Answer: 8
| | | | | | | | Question: What is the output of this program?
#include #include int main() { int *ptr; ptr = (int *)calloc(1,sizeof(int)); if (ptr != 0) printf("%d ",*ptr); return 0; } | | Answer: 0
| | | | | | | | Question: What is the output of this program?
#include #include int main() { int *ptr; *ptr = 10; *ptr = 20; printf("%d ",*ptr); return 0; } | | Answer: Segmentation fault
| | | | | | | | Question: In this program the allocated memory block can store #include #include int main() { int *ptr; ptr = malloc(10); return 0; }
| | Answer: All of the mentioned options
| | | | | | | | | | | | |