Memory Management in C

MEMORY MANAGEMENT memory cell , Residence memory segmentation offset address data segment, stack, data , heap, code area STRUCTURE AND UNION What is structure We cannot assign different type structure to other... Initialization of structure member variable Why we cannot use relation and logical operators i.. Bit level programming: pointer in bit level programming important pint for bit level programming Misuse of pinter in structure : array, union, Structure in the structure ADVANCE C system level programming. Write the c program to switch the 256 color graphic.. Project in C Command line arguent in c How to create dos command in c ? Create dir command in c How to create virus in c? Write a program which shutdown the window operation. Write a c which delete the all the . exe file of in .. Mouse programming in c DATA TYPE and Qualifier size of data type, const and volatile memory map of char endianness memory map of int memory map of float, double , cyclic nature of data type , enum ,typedef,Constant in C good question FUNCTION Syntax of function in c How to make user defined function as library function Function in c with no paramete and not returning.. Function in c has parameter but not returning any.. function in c with parameter and returning a value. what is ellipsis or in c ?What is main function in c? parameter passing conventionin c : pascal and cdec.. Function recursion in PREPROCESSOR preprocessor directives#define #include #,## # pragma # pragma inline # pragma wrn # pragma startup, # pragma exit #error, # line

(8) What is data segment?
Ans:
Segment number 8 has special name which is known as data segment.
It has divided into four parts.




Stack area:-
All automatic variables are created into stack area.Default storage class of any local variable is auto.This variable may be int, char, float, array, pointer, struct, union etc.It also return fuction argument and return address.It follow LIFO datastructure. It has two part one for initialize variable another for non-initialize variable.All initialize variable are more nearer than unintialize variable and vice versa.

Data area :
All static and extern variable are created in the data area.
Heap area:
Malloc and calloc always allocate memory in the heap area.It is used for dynamic memory allocation.It’s size depends upon free space in the memory.
Code area:
Fuction pointer can only access code area.Size of this area is always fixed and it is read only area.

(9) What will output:
void main()
{
int a=5,b=6,c=7;
printf(“%d,%d,%d”);
}
Ans:
Output: 7 6 5
Explanation:


Default sotrage class int a=5 is auto.Since it automatic variable it will create in the stack area.
It will store in the stack as
Stack always follows LIFO datastructure.
In the printf statement name of variable is not written explicitly.So default output will content of
Stack which will be in the LIFO order i.e 7 6 5.
(10) what will be output:
void main()
{
int a=5 ,b,c=7;
printf(“%d %d %d”);
}
Ans:
Output: 7 5 garbage value
Explanation:
Automatic variable a and c has initialized while b has not initilize.Initialize variable are more nearer than non initialize variable .They will be stored in the stack.So due to LIFO first output will be 7 then 6 (since a is more nearer than b with respect to c) then any garbage value will be output which is persent in the stack.

0 comments:

Followers

 
C - Programming -