C Program to Calculate Size of Structure using Sizeof Operator


Levels of difficulty: / perform operation:

C Program

#include<stdio.h>
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);
	return(0);
}

Size of the Structure Can be Evaluated using “sizeof Operator”

total size =   sizeof(roll) + sizeof(name) + sizeof(mark)