Professional Documents
Culture Documents
C Programming::: Memory Allocation
C Programming::: Memory Allocation
Search
Aptitude Reasoning Verbal Ability GK Puzzles Programming Database Engineering Interview Online Test
Exercise
6.
Assume integer is 2 bytes wide. What will be the output of the following code?
General Questions Find Output of Program Point Out Errors Point Out Correct Statements True / False Questions Yes / No Questions
"Life is like riding a bicycle. To keep your balance you must keep moving." - Albert Einstein
Answer: Option A
Explanation:
7.
#include<stdio.h> #include<stdlib.h>
int main() { int *p; p = (int *)malloc(256 * 256); if(p == NULL) printf("Allocation failed"); return 0; } A. C. 65536 Error B. D. Allocation failed No output
Answer: Option B
Explanation: Hence 256*256 = 65536 is passed to malloc() function which can allocate upto 65535. So the memory allocation will be failed in 16 bit platform (Turbo C in DOS).
If you compile the same program in 32 bit platform like Linux (GCC Compiler) it may allocate the required memory.
< Prev 12
Read more:
Memory Allocation - Point Out Errors Memory Allocation - Point Out Correct Statements Memory Allocation - True / False Questions Memory Allocation - Yes / No Questions
2008-2011 by IndiaBIX Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy Advertise Contact us: info@indiabix.com Follow us on twitter!
Bookmark to: