Cases where prepositions come at the end of clauses

A preposition connects two things: a noun, an adjective or a verb that comes before it and a noun phrase or a pronoun that comes after it.

We have bought a present for you.
The cat is on the roof.
She smiled at him.
I am really angry with Susie.

In some sentences, the object of the preposition may come at or near the beginning of a clause. In such cases, the preposition does not always go with its object: it may come at the end of the clause. This usually happens in the following cases:

Wh-questions
The preposition comes at the end of a wh-question.This is common in informal  usage.

Who is this present for? (For whom is this present? is extremely formal.)
What are you looking at? (More natural than ‘At what are you looking?’)
Where did you buy it from?
Who did she go with?

In indirect wh-questions also the preposition usually comes at the end.

Tell me what you are thinking about.

The preposition may also come at the end of what-clauses which are not questions.

What a lot of trouble I am in!

Relative structures

When a relative pronoun is the object of a preposition, the preposition usually goes at the end of the clause.

That is what I am asking about.
This is the girl that I told you about.
It is Peter that I am angry with.

Passives
In passive structures prepositions go with their verbs.

She likes to be looked at.
She was operated on last night.

Infinitive structures

Infinitive complements can also have prepositions with them.

That was a great place to live in.
She needs other children to play with.