-
Notifications
You must be signed in to change notification settings - Fork 0
/
010_Student_nested_structure
48 lines (42 loc) · 1.3 KB
/
010_Student_nested_structure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Div name is char[50] and year in college is "int".Then read your information into the fields:Name, age, DOB, roll_number_marks, Div name, year in college.
lastly, write out these fields to the output.*/
#include <stdio.h>
struct person
{
char name[50];
int age;
char dob[10];
};
struct student
{
struct person info;
int roll_no;
float marks;
int YearInCollege;
char DeptName[50];
};
int main(){
struct student s1;
printf("Enter name: ");
scanf("%s", s1.info.name);
printf("Enter DOB: ");
scanf("%s",s1.info.dob);
printf("Enter Age: ");
scanf("%d", &s1.info.age);
printf("Enter Roll No: ");
scanf("%d",&s1.roll_no);
printf("Enter Department: ");
scanf("%s",s1.DeptName);
printf("Enter Year in College: ");
scanf("%d",&s1.YearInCollege);
printf("Enter Marks: ");
scanf("%f",&s1.marks);
printf("\nDisplay Student Information\n");
printf("Name:%s\n",s1.info.name);
printf("DOB:%s\n",s1.info.dob);
printf("Age:%d\n",s1.info.age);
printf("Roll No:%d\n",s1.roll_no);
printf("Department:%s\n",s1.DeptName);
printf("Year in College:%d\n",s1.YearInCollege);
printf("Marks:%.2f\n",s1.marks);
}