diff --git a/Hackerrank/gradingStudents.c b/Hackerrank/gradingStudents.c new file mode 100644 index 0000000..768160e --- /dev/null +++ b/Hackerrank/gradingStudents.c @@ -0,0 +1,37 @@ +#include +#include + + +/* GRADING STUDENTS PROBLEM +Sam is a professor at the university and likes to round each student's grades according to these rules: + +If the difference between the grade and the next multiple of 5 is less than 3, round grade up to the next multiple of 5. +If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade. +*/ + + +int* gradingStudents(int *grades, int size){ + for(int i=0;i 2 && grades[i] >= 38) + grades[i] += (5 - (grades[i] % 5)); + } + return grades; +} + + +int main(){ + int i,n; + printf("Enter number of students : "); + scanf("%d",&n); + int *marks = (int*)calloc(n,sizeof(int)); + printf("Enter grades of students : "); + for(i=0;i