Calculate Size of Structure
Size of Structure can be calculated as -
- By observation
- By Using sizeof Operator
- Without using Sizeof Operator
struct Book
{
int pages;
char name[10];
char author[10];
float price;
}b1;Calculating Size of Structure := size of 'Pages' + size of 'Name' + size of 'Author' + size of 'Price'
= 2 + 10 * 1 + 10 * 1 + 4
= 2 + 10 + 10 + 4
= 26
Note :
- Add all the individual Size of Each Structure Member .
- Character array requires Memory Equivalent to (No_of_elements * Sizeof(char))
- Float , Integer requires 4,2 bytes respectively in Case of Borland CC++ 3.0
Way 2 : Using Sizeof Operator
printf("Size of Structure : %d",sizeof(b1));
Way3 : Without Using Sizeof Operator : Click Here

0 comments
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email