/*WAP of Student record using Structure in c*/
#include<stdio.h>
#include<conio.h>
struct student
{
int rollno, marks1,marks2,marks3,tot;
char name[25],grade;
float per;
};
void main()
{
struct student s; //Data type of '*s' is struct student
clrscr();
//take input from user
printf("Enter Student Roll Number: ");
scanf("%d", &s.rollno);
printf("\nEnter Student name: ");
scanf("%s", s.name);
printf("\nEnter Student 3 subject's marks: ");
scanf("%d%d%d", &s.marks1,&s.marks2,&s.marks3);
//calculation
s.tot = s.marks1 + s.marks2 + s.marks3;
s.per = s.tot/3;
if(s.per>=75){
s.grade = 'A';
}
else if(s.per<75 && s.per>=60){
s.grade = 'B';
}
else if(s.per<60 && s.per>=50){
s.grade = 'C';
}
else if(s.per<50 && s.per>=40){
s.grade = 'D';
}
else if(s.per<40 && s.per>=33){
s.grade = 'E';
}
else {
s.grade = 'F';
}
//Display result
printf("\n==================================\n");
printf("\nStudent's Roll no. - %d", s.rollno);
printf("\nStudent's Name - %s", s.name);
printf("\nStudent's Total Marks - %d", s.tot);
printf("\nStudent's Percentage - %f", s.per);
printf("\nStudent's Grade - %c", s.grade);
getch();
}
No comments:
Post a Comment