These are situations where you can use ordinal numbers, as opposed to cardinal numbers. If you look up "ordinal/cardinal" you can get more information. In a line, you can ask someone "Are you first/second/third/fourth in line?". In the race situation, you can ask someone "Did you come first/second/third/fourth in the race?"
However, in real-life situations, you might hear things phrased differently. When we are queuing and want to find out information about people in line, the most common question we hear is something like "Excuse me, are you next in line or I am?" ...In the race situation, the question might be "How did you do in the race?" Or "Did you win the race?"