Here are the rules that apply if the general electon results in a hung parliament:
(Full details on parliament web site here)
1. The Conservatives get first chance at forming a government as they are the incumbents.
2. If they can not secure one then the Prime Minister has to resign.
3. The Queen would then invite the leader of the largest other party to try and form a government (i.e. Ed Miliband).
4. If this fails then he could propose a Queen's speech and try and get it passed.
5. If this fails there could be a vote of no confidence and parliament would be dissolved for another election to take place (according to then Fixed-term Parliaments Act 2011).
As the new House of Commons starts sitting on Monday 18th of May this leaves only nine days for negotiations with potential coalition partners.