Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f5c3903

Browse files
create structures.c
1 parent 9edd595 commit f5c3903

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

‎structures.c‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*Structures (also called structs) are a way to group several related variables into one place.
2+
Each variable in the structure is known as a member of the structure.
3+
Unlike an array, a structure can contain many different data types (int, float, char, etc.).
4+
specifications: get the student roll number,name and marks as input and display the grade of student according to the marks*/
5+
6+
#include<stdio.h>
7+
struct student
8+
{
9+
int rollno;
10+
char name[50];
11+
float marks;
12+
};
13+
struct student s[3];
14+
void main()
15+
{
16+
for(int i=0;i<3;i++){
17+
printf("\nenter the student roll number:");
18+
scanf("%d",&s[i].rollno);
19+
printf("enter the student name:");
20+
scanf("%s",s[i].name);
21+
printf("enter the student marks (out of 100):");
22+
scanf("%f",&s[i].marks);
23+
24+
if(s[i].marks>90){
25+
26+
printf("\ngrade of student %s is S",s[i].name);
27+
28+
}
29+
else if(s[i].marks>80&&s[i].marks<=90)
30+
{
31+
printf("\ngrade of student %s is A",s[i].name);
32+
}
33+
else if(s[i].marks>60&&s[i].marks<=80)
34+
{
35+
36+
printf("\ngrade of student %s is B",s[i].name);
37+
38+
}
39+
else if(s[i].marks>40&&s[i].marks<=60)
40+
{
41+
printf("\ngrade of student %s is C",s[i].name);
42+
43+
}
44+
45+
else if(s[i].marks<=40)
46+
{
47+
printf("\ngrade of student %s is F",s[i].name);
48+
49+
}
50+
}
51+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /