-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructure2.c
More file actions
39 lines (39 loc) · 822 Bytes
/
structure2.c
File metadata and controls
39 lines (39 loc) · 822 Bytes
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
// Write a program to store the data of 3 students
#include<stdio.h>
struct student
{
int roll;
char name[70];
float CGPA;
};
void dataEntry( struct student *a);
void checkData(struct student a);
int main()
{
struct student a[3];
printf("Enter students data below \n");
for(int i=0;i<3;i++)
{
dataEntry(&a[i]);
}
printf("We have these records \n\n");
for(int i=0;i<3;i++)
{
checkData(a[i]);
}
return 0;
}
void dataEntry(struct student *a)
{
printf("Enter roll no : ");
scanf("%d",&a->roll);
printf("Enter name : ");
scanf(" %[^\n]s",a->name);
printf("Enter CGPA : ");
scanf("%f",&a->CGPA);
}
void checkData(struct student a)
{
printf("Roll: %d, Name : %s, CGPA :%.1f, \n",a.roll,a.name,a.CGPA);
printf("\n");
}