Last active
July 28, 2017 16:47
-
-
Save d1p/ad2ad3c456237cedbdc46aa11c411665 to your computer and use it in GitHub Desktop.
Homework..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
typedef struct | |
{ | |
char name[40]; | |
int math; | |
int bangla; | |
int english; | |
int total; | |
float avarage; | |
char grade[1]; | |
} Student; | |
int main(void) | |
{ | |
Student student[4]; | |
int i; | |
for (i = 0; i <= 4; i++) | |
{ | |
printf("Enter the marks for student %d\n", i + 1); | |
printf("Name: "); | |
scanf("%s", student[i].name); | |
printf("Math: "); | |
scanf("%d", &student[i].math); | |
printf("Bangla: "); | |
scanf("%d", &student[i].bangla); | |
printf("English: "); | |
scanf("%d", &student[i].english); | |
student[i].avarage = (student[i].bangla + student[i].english + student[i].math) / 3; | |
student[i].total = student[i].bangla + student[i].english + student[i].math; | |
if (student[i].avarage < 40) | |
{ | |
strcpy(student[i].grade, "F"); | |
} | |
else if (student[i].avarage >= 40 && student[i].avarage < 60) | |
{ | |
strcpy(student[i].grade, "B"); | |
} | |
else if (student[i].avarage >= 60 && student[i].avarage < 80) | |
{ | |
strcpy(student[i].grade, "A"); | |
} | |
else | |
{ | |
strcpy(student[i].grade, "A+"); | |
} | |
} | |
printf("Serial\tName\tEng\tMath\tBan\tTotal\tAvarage\tGrade\n"); | |
for (i = 0; i <= 4; i++) | |
{ | |
printf("%d\t%s\t%d\t%d\t%d\t%d\t%.2f\t%s\n", i + 1, student[i].name, student[i].english, student[i].math, student[i].bangla, student[i].total, student[i].avarage, student[i].grade); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment