Number of students ahead of Mahesh in rank = 42 - 16 = 26
So Mahesh's rank is 27th from the top
This question can be solved by formula also
Rank of a person from upper or left end = (Total number of persons in row) - (Rank of that person from lower or right end) - 1 Mahesh's rank from the top
= 42 - 16 + 1 = 27.