| | | | Question Answer Tutorial - Linux->Memory | | | | Question: What is the output of this program? #include #include int main() { int ret; int *ptr; ptr = (int *)malloc(sizeof(int)*10); free(ptr); free(ptr); return 0; } | | Answer: Undefined behaviour
| | | | | | | | Question: This program will allocate the memory of ___ bytes for pointer "ptr".
#include #include int main() { int *ptr; ptr = (int*)malloc(sizeof(int)*4); ptr = realloc(ptr,sizeof(int)*2); return 0; } | | Answer: 8
| | | | | | | | Question: In this program the two printed memory locations has the difference of ___ bytes.
#include #include int main() { int *ptr; ptr = (int*)malloc(sizeof(int)*2); printf("%p ",ptr); printf("%p ",ptr+1); return 0; } | | Answer: 4
| | | | | | | | Question: What is the output of this program?
#include #include #include int main() { char *ptr; memcpy(ptr,"MCQTutorial",11); printf("%s ",ptr); return 0; } | | Answer: Segmentation fault
| | | | | | | | Question: Which one of the following in true about this program?
#include #include #include int main() { char *ptr; printf("%p ",ptr); ptr = (char *)malloc(sizeof(char)); printf("%p ",ptr); return 0; } | | Answer: None of the mentioned options
| | | | | | | | | | | | |