Question 17 || Hacker Rank
Student Marks Sum || Hacker Rank
You are
given a variety of whole numbers, marks, signifying the imprints scored
by understudies in a class.
The rotating
components , marks0,marks2,marks4
etc signify the characteristics of young men.
Likewise,
marks1,marks3,marks5, etc
signify the characteristics of young ladies.
The cluster
name, marks, functions as a pointer which stores the base location of
that exhibit. At the end of the day, contains the marks location where
is put away in the memory.
For
instance, let and stores marks = [3, 2, 5]. Then, is stores
0x7fff957c05f and 0x7fff9575c05f is the memory address of marks0.
Capability
Depiction
Complete the
capability, marks_summation in the manager beneath.
marks_summation
has the accompanying boundaries:
· int marks[number_of_students]: the imprints
for every understudy
· int number_of_students: the size of
marks[]
· scorch orientation: either 'g' or 'b'
Returns
· int: the amount of imprints for young
men if gender = b, or of signs of young ladies if gender = g
Input
Arrangement
The
principal line contains number_of_students, signifying the quantity of
understudies in the class, thus the quantity of components in marks.
Every one of
the resulting lines contains number_of_students.
The
following line contains marksi.
Limitations
Test
Information 0
3
3
2
5
B
Test
Result 0
8
Clarification
0
marks = [3,
2, 5] and gender = b .
Thus,
marks0
+ marks2 = 3+5 = 8
Test
Information 1
5
1
2
3
4
5
G
Test
Result 1
6
Clarification
1
marks = [1, 2, 3, 4, 5] and gender =
g
Thus,
Sum =
marks1 + marks3 = 2+5 = 8.
Test
Information 2
1
5
G
Test
Result 2
0
Clarification
2
marks = [5] and gender = g
Here, marks1
doesn't exist. Thus, sum = 0.
0 Comments