Practice

Highest Student Record

MEDIUMData Types8 marks

Define a record type named Student with a name and integer mark. Read three student records and output the name and mark of the student with the highest mark.

If marks are equal, keep the student who was entered first.

Input: Three pairs of name and mark. Output: The winning name followed by the mark on the next line.

Example:

Input:  Amal
        71
        Ben
        88
        Chen
        79
Output: Ben
        88

Sample Test Cases

Test 1: Second student highest
Inputs: Amal, 71, Ben, 88, Chen, 79
Expected: Ben 88
Test 2: First student highest
Inputs: Ari, 95, Bea, 80, Cal, 90
Expected: Ari 95

Premium Question

This question needs a paid plan — upgrade, or join a class from a teacher who has one. You can read the description and sample tests, but grading is locked.

Sign in to get started