Calculate Size of Structure - C Language Programming

Program in C Language to Calculate Size of Structure

Click here to open this program in Turbo C++

 Statement - Calculate Size of Structure
 Programmer - Vineet Choudhary
 Written For -


struct stud {
    int roll;
    char name[10];
    int marks;

int main() {
    int size;
    struct stud s;
    size = sizeof(s);
    printf("nSize of Structure : %d", size);

 Explanation :
 Structure is Collection of elements of the Different data Types.
 Size of the Structure Can be Evaluated using “sizeof Operator”
 size = sizeof(s);
 Formula for Calculating Size of Structure :
 Size of Structure 'S' = sizeof(roll) + sizeof(name) + sizeof(mark)
 = 2 + 10 + 2
 = 14
 ->Size depends on your computer
 Remember :
 sizeof is Operator not function
 sizeof Operator Takes any Variable as Parameter.
You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.