forked from singhofen/c-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structures.c
51 lines (42 loc) · 1.14 KB
/
structures.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
/*Structures (also called structs) are a way to group several related variables into one place.
Each variable in the structure is known as a member of the structure.
Unlike an array, a structure can contain many different data types (int, float, char, etc.).
specifications: get the student roll number,name and marks as input and display the grade of student according to the marks*/
#include<stdio.h>
struct student
{
int rollno;
char name[50];
float marks;
};
struct student s[3];
void main()
{
for(int i=0;i<3;i++){
printf("\nenter the student roll number:");
scanf("%d",&s[i].rollno);
printf("enter the student name:");
scanf("%s",s[i].name);
printf("enter the student marks (out of 100):");
scanf("%f",&s[i].marks);
if(s[i].marks>90){
printf("\ngrade of student %s is S",s[i].name);
}
else if(s[i].marks>80&&s[i].marks<=90)
{
printf("\ngrade of student %s is A",s[i].name);
}
else if(s[i].marks>60&&s[i].marks<=80)
{
printf("\ngrade of student %s is B",s[i].name);
}
else if(s[i].marks>40&&s[i].marks<=60)
{
printf("\ngrade of student %s is C",s[i].name);
}
else if(s[i].marks<=40)
{
printf("\ngrade of student %s is F",s[i].name);
}
}
}