David Cameron has resigned as Prime Minister after the United Kingdom voted to leave the European Union.