-
Notifications
You must be signed in to change notification settings - Fork 2
/
Structures4.c
65 lines (62 loc) · 2.16 KB
/
Structures4.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
@Author: Raghav Maheshwari
This is a program depicting the arrays of structures...
*/
#include<stdio.h>
#include<string.h>
void main(){
printf("\n-----Some Info----");
printf("Enter the Number of students in the class");
int n;
scanf("%d",&n);
struct student{
int roll_no;
char name[80];
float fees;
char DOB[20];
};
struct student stud[50];
for(int i=0;i<n;i++){
printf("\n----------------Enter the details of student %d---------------",i+1);
printf("\nEnter your roll no\t");
scanf("%d",&stud[i].roll_no);
printf("\nEnter your name\t");
scanf("%s",stud[i].name);
printf("\nEnter the fees of the student\t");
scanf("%f",&stud[i].fees);
printf("\nEnter the date of birth of the student\t");
scanf("%s",stud[i].DOB);
}
for(int i=0;i<n;i++){
printf("\n----------------Details of student %d are---------------",i+1);
printf("\nRoll No:\t%d",stud[i].roll_no);
printf("\nName;\t%s",stud[i].name);
printf("\nFees:\t%f",stud[i].fees);
printf("\nDOB:\t%s",stud[i].DOB);
}
printf("\nEnter the num of student whose details are to be edited");
int num;
scanf("%d",&num);
num = num-1;
int roll_no;
char name[80];
float fees;
char DOB[20];
printf("\nEnter the new roll no\t");
scanf("%d",&roll_no);
printf("\nEnter the new name\t");
scanf("%s",name);
printf("\nEnter the new fees of the student\t");
scanf("%f",&fees);
printf("\nEnter the new date of birth of the student\t");
scanf("%s",DOB);
stud[num].roll_no = roll_no;
strcpy(stud[num].name,name);
stud[num].fees = fees;
strcpy(stud[num].DOB,DOB);
printf("\n----------------Edited Details of student are---------------");
printf("\nRoll No:\t%d",stud[num].roll_no);
printf("\nName;\t%s",stud[num].name);
printf("\nFees:\t%f",stud[num].fees);
printf("\nDOB:\t%s",stud[num].DOB);
}