Students Marks Sum

  • + 0 comments

    shortest way to do this is probably

    int marks_summation(int* marks, int number_of_students, char gender)
    {
        // Write your code here.
        int sum = 0;
        int i = (gender == 'g');
    
        while (i < number_of_students) {
            sum += marks[i];
            i += 2;
        }
        return sum;
    }