PROBLEM IN SOLVING TWO-DIMENSIONAL ARRAY

Please give some hints to solve the following program

Read roll number and height of ten students and store it in an array as the first column containing the roll number and the second column containing the corresponding height. Display the rollnumber and height of the tallest student.

I tried this program and I can only display height of the tallest student.
How can I display roll number with the corresponding height.
Please help.....
Why do you need a 2D array for this? Why not just an array of

1
2
3
4
struct student {
    /* element for roll number */
    /* element for height */
};


Then walk the array and find the student (element) with the tallest height and print
out both fields of the struct.
In all fairness jsmith, he might not have got far enough to use structures... like me :(

I would use a loop to get the 10 user inputs of height and roll number and put them in a 2d array. Then use another loop to cycle through the height column to find the highest value and then display it with the corresponding roll number element.

Last edited on
True. And yet another solution would be to have two independent but parallel arrays, one for the
heights and one for the rolls.

Not sure which approach OP is using.
SJK, you said that you tried the program and that the output was not what you wanted. Please post your code. The problem could be something as simple as a typo. On the other hand, it could also be a major conceptual error.
Topic archived. No new replies allowed.