-
Notifications
You must be signed in to change notification settings - Fork 0
/
06.struct.c
51 lines (46 loc) · 1.07 KB
/
06.struct.c
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
49
50
51
#include <stdio.h>
#include <stdlib.h>
struct student
{
char Stud_Name[30];
int Stud_No;
int Stud_Marks[5];
int Stud_Totals;
};
int main()
{
struct student detail[5];
FILE *fptr;
int i, j;
fptr = fopen("STUD_TETAIL", "w");
if (fptr == NULL)
{
printf("file not created");
}
//read information
for (size_t i = 0; i < 5; i++)
{
printf("STUDENT_NAME:");
fgets(detail[i].Stud_Name, 30, stdin);
printf("STUDENT_NO:");
scanf("%d", detail[i].Stud_No);
printf("STUDENT MARKS:");
for (size_t j = 0; j < 5; j++)
{
scanf("%d", detail[i].Stud_Marks);
}
//print output
for (size_t i = 0; i < 5; i++)
{
printf("FIRST_STUDENT_DETAIL:\n");
puts(detail[i].Stud_Name);
printf("\n");
printf("%d\n", detail[i].Stud_No);
printf("STUDENT_MARKS");
for (size_t j = 0; i < 5; j++)
{
printf("%d", detail[i].Stud_Marks[i]);
}
}
}
}