Although it can be nerve-wracking, asking a girl to exchange numbers is often the first step to pursuing a dating relationship. You may find that, if approached respectfully, many girls are open to giving out their number. There is no way to guarantee that each attempt to get a girl's phone number will be successful, but failing to ask guarantees that you won't get her number.
Start a conversation with the girl, ask if she'd like to continue the conversation later and then ask for her number. This approach is simple.
Ask the girl if she'd like to get together after school or work. If she agrees, ask for her number so that you can arrange to pick her up. If she declines, ask for her number anyway. Although this approach is more bold than the other, it solidifies the thought that you are interested in dating her, which may prevent you from being considered "just a friend."
Look for an opportunity to do something with the girl, such as collaborating on a project for work or school, and ask to exchange numbers. This technique sends the message that you would like to talk, but maybe only as a friend or acquaintance.