Hello coders, today we are going to solve** Grading Students HackerRank Solution** which is a Part of **HackerRank Algorithm** Series.

Contents

**Task**

HackerLand University has the following grading policy:

- Every student receives a
in the inclusive range from**grade****0**to**100**. - Any
less than**grade****40**is a failing grade.

Sam is a professor at the university and likes to round each student’s * grade* according to these rules:

- If the difference between the
and the next multiple of**grade****5**is less than**3**, roundup to the next multiple of**grade****5**. - If the value of
is less than**grade****38**, no rounding occurs as the result will still be a failing grade.

**Examples**

**grade****= 84**round to**85**(85 – 84 is less than 3)**grade****= 29**do not round (result is less than 40)**grade****= 57**do not round (60 – 57 is 3 or higher)

Given the initial value of * grade* for each of Sam’s

**students, write code to automate the rounding process.**

*n***Function Description**

Complete the function *gradingStudents* in the editor below.

gradingStudents has the following parameter(s):

*int grades[n]*: the grades before rounding

**Returns**

*int[n]*: the grades after rounding as appropriate

**Input Format**

The first line contains a single integer, ** n**, the number of students.

Each line

**of the**

*i***subsequent lines contains a single integer,**

*n***.**

*grades*[*i*]**Constraints**

**1 <=***n*<= 60**0 <=***grades*[*i*] <= 100

**Sample Input 0**

```
4
73
67
38
33
```

**Sample Output 0**

```
75
67
40
33
```

**Explanation 0**

- StudentÂ
**1**Â received aÂ**73**, and the next multiple ofÂ**5**Â fromÂ**73**Â isÂ**75**. SinceÂ**75 – 73 < 3**, the student’s grade is rounded toÂ**75**. - StudentÂ
**2**Â received aÂ**67**, and the next multiple ofÂ**5**Â fromÂ**67**Â isÂ**70**. SinceÂ**70 – 67 = 3**, the grade will not be modified and the student’s final grade isÂ**67**. - StudentÂ
**3**Â received aÂ**38**, and the next multiple ofÂ**5**Â fromÂ**38**Â isÂ**40**. SinceÂ**40 – 38 < 3**, the student’s grade will be rounded toÂ**40**. - StudentÂ
**4**Â received a grade belowÂ**33**, so the grade will not be modified and the student’s final grade isÂ**33**.

**Solution – Grading Students**

**C++**

#include <bits/stdc++.h> using namespace std; void solution() { int n, x; cin>>n; for(int i=0; i<n; i++){ cin>>x; if(x>=38 and x%5>=3){ while(x%5!=0){ x++; } } cout<<x<<endl; } } int main () { solution(); return 0; }

**Python**

n = int(input().strip()) for a0 in range(n): grade = int(input().strip()) if grade >= 38: mod5 = grade % 5 if mod5 >= 3: grade = grade + (5 - mod5) print(grade)

**Disclaimer:** The above Problem **(Grading Students)** is generated by **Hacker Rank **but the Solution is Provided by **CodingBroz**. This tutorial is only for **Educational** and **Learning** Purpose.