Nested structure 1 in C.

 

01  #include<stdio.h>
02
03 struct University
04 {
05 int uniCode;
06 char uniName[30];
07 };
08
09
10 struct College
11 {
12 int clgCode;
13 char clgName[30];
14 struct University u;
15 }c;
16
17 int main()
18 {
19 printf("Enter Details : n");
20
21 printf("College Code : ");
22 scanf("%d",&c.clgCode);
23 fflush(stdin);
24
25 printf("College Name : ");
26 gets(c.clgName);
27
28 printf("University Code : ");
29 scanf("%d",&c.u.uniCode);
30 fflush(stdin);
31
32 printf("University Name : ");
33 gets(c.u.uniName);
34
35 printf("----------------------n");
36 printf("Details : n");
37 printf("----------------------n");
38
39 printf("College Code : %d n",c.clgCode);
40 printf("College Name : %s n",c.clgName);
41 printf("University Code : %d n",c.u.uniCode);
42 printf("University Name : %s",c.u.uniName);
43
44 return 0;
45 }
 
 
 OUTPUT :

Enter Details :
College Code : 1216
College Name : SRSS
University Code : 3422
University Name : TYYU

----------------------
Details :
----------------------

College Code : 1216
College Name : SRSS
University Code : 3422
University Name : TYYU

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *