HackerRank C- Grading Students




Complete the function gradingStudents in the editor below. It should return an integer array consisting of rounded grades.

gradingStudents has the following parameter(s):

grades: an array of integers representing grades before rounding



  1. #include<stdio.h>
  2. int main() {
  3. int n, e = 0;
  4. scanf("%d",&n);
  5. int a[n];
  6. for (int i = 0; i < n; i++) {
  7. scanf("%d",&a[i]);
  8. }
  9. for (int i = 0; i < n; i++) {
  10. if (a[i] >= 38) {
  11. for (int j = a[i]; e != 1; j++) {
  12. if (j % 5 == 0) {
  13. if (j - a[i] < 3) {
  14. a[i] = j;
  15. } else if (j - a[i] == 3) {
  16. a[i] = a[i];
  17. }
  18. e = 1;
  19. }
  20. }
  21. e = 0;
  22. }
  23. else {
  24. a[i] = a[i];
  25. }
  26. }
  27. for (int i = 0; i < n; i++) {
  28. printf("%d\n",a[i]);
  29. }
  30. }




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube