C Program to calculate size of a structure
Program
#include<stdio.h>
struct student
{
int usn;
char name[20];
float marks;
}s;
void main()
{
printf("Size of field USN is %d\n", sizeof(s.usn));
printf("Size of field Name is %d\n", sizeof(s.name));
printf("Size of field Marks is %d\n", sizeof(s.marks));
printf("Size of structure is %d bytes\n", sizeof(s));
}
Output
Size of field USN is 4
Size of field Name is 20
Size of field Marks is 4
Size of structure is 28 bytes