Thursday, January 16, 2020

Students Marks Sum - Hacker Rank Solution

You are given an array of integers, , denoting the marks scored by students in a class.
  • The alternating elements  and so on denote the marks of boys.
  • Similarly,  and so on denote the marks of girls.

Students Marks Sum - Hacker Rank Solution

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int marks_summation(int* p, int number_of_students, char gender) {
    int s = 0, i = 0;
    if (gender == 'g') {
        i++;
    }
    for (; i < number_of_students; i = i+2) {
        s += p[i];       
    }
    return s;
}

2 comments:

  1. where we did define boys in the above mentioned code?
    still the code is running fine !!!!

    can anyone help me out from this confusion?

    ReplyDelete
  2. Informative content ! :)
    Also check Students Marks Sum – Hacker Rank Solution
    https://www.codeworld19.com/students-marks-sum-hacker-rank-solution/

    ReplyDelete

Powered by Blogger.