Your program asks a recursive resolver (for example a public one or your ISP’s). It walks from the root to the TLD to the authoritative server and returns the final answer, caching along the way.