-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct7.c
More file actions
63 lines (56 loc) · 1.08 KB
/
struct7.c
File metadata and controls
63 lines (56 loc) · 1.08 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
#include<stdio.h>
struct student
{
int roll;
float per;
char name[30];
};
void addstud(struct student *s)
{
printf("Enter student Rollnumber:");
scanf("%d",&s->roll);
printf("Enter student Percentage:");
scanf("%f",&s->per);
printf("Enter student Name:");
scanf("%s",s->name);
}
void showstud(struct student s)
{
printf("\n Now Displaying Students Details as:\n");
printf("\n Name:%s",s.name);
printf("\n RollNumber:%d",s.roll);
printf("\n Marks:%f",s.per);
}
void updatemark(struct student *s)
{
int nmarks;
printf("\n Enter new marks:");
scanf("%d",&nmarks);
s->per=nmarks;
}
int main()
{
int i,troll;
int n;
struct student *s[10];
printf("\nHow many students are in Class:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
s[i]=(struct student*)malloc(sizeof(struct student));
addstud(s[i]);
}
printf("\nWhich student marks you want to modify. Enter roll number:");
scanf("%d",&troll);
for(i=0;i<n;i++)
{
if(s[i]->roll==troll)
{
updatemark(s[i]);
}
}
for(i=0;i<n;i++)
{
showstud(*s[i]);
}
}