Thursday, December 25, 2014

DIFFERENCE BETWEEN STRUCTURE & UNION

Structure take individual memory space for each variable while union takes largest memory space & all variable share its. 

Example of Structure
struct emp
{
 int code;
 char name[20];
 float sal;
};
intà2bytes
stringà20bytes
floatà4bytes

Total Memory occupiedà26bytes

Example of Union
union emp
{
 int code;
 char name[20];
 float sal;
};

Total Memory occupied à20bytes

No comments:

Post a Comment

Programmingway@Eklavya Technosys!: JAC Board Computer Examination Sample Questions Hi...

Programmingway@Eklavya Technosys!: JAC Board Computer Examination Sample Questions Hi... : 1) Which of the following is NOT a web service? (...