Skip to content

Commit b52b74e

Browse files
added uninon
1 parent 5752e6a commit b52b74e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

C/uninon.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//sizeof() an union example
2+
3+
#include<stdio.h>
4+
void main()
5+
{
6+
int a;
7+
float b;
8+
struct student_details
9+
{
10+
char name[20];
11+
int regno;
12+
}student;
13+
14+
union code
15+
{
16+
int x;
17+
char c;
18+
float y;
19+
}sample;
20+
21+
printf("size of variable a=%d\n",sizeof(a));
22+
printf("size of variable b=%d\n",sizeof(b));
23+
printf("size of structure variable is %d\n",sizeof(student));
24+
printf("size of union variable is %d\n",sizeof(sample));
25+
printf("size of integer is %d\n",sizeof(int));
26+
27+
}

0 commit comments

Comments
 (0)