Barack Obama has said EU membership makes Britain a “bigger player” on the world stage and enhances its “special relationship” with America.
The US president said UK voters must decide their own future – but their decision could affect US prosperity.
And he warned Britain would be at the “back of the queue” for striking trade deals with the US if it left the EU.
The US President earlier had lunch with the Queen with his wife Michelle at the start of a three day visit to the UK.
He paid warm tribute to the Queen on her 90th birthday describing her as “truly one of my favourite people”.
Speaking at a joint press conference, Mr Cameron said being a member of the EU strengthened Britain’s “special relationship” with the US.
On the EU referendum, he said: “This is our choice – nobody else’s – the sovereign choice of the British people – but as we make that choice, it surely makes sense to listen to what our friends think.”
Mr Obama said: “The UK is at its best when it’s helping to lead a strong European Union. It leverages UK power to be part of the EU. I don’t think the EU moderates British influence in the world, it magnifies it.
“America wants Britain’s influence to grow, including within Europe.”
On whether he should be intervening in the UK’s EU referendum, he said: “Let me be clear: ultimately this is something the British voters have to decide for themselves.
“As part of our special relationship, part of being friends is to be honest and to let you know what I think, and speaking honestly, the outcome of that decision is a matter of deep interest to the US, because it affects our prosperity as well.”
Mr Obama’s intervention into the EU referendum debate has been criticised as “hypocritical” by London Mayor and EU leave campaigner Boris Johnson and UKIP leader Nigel Farage said he was the most anti-British US president ever.
The Duke and Duchess of Cambridge and Prince Harry will welcome the Obamas for dinner at Kensington Palace on Friday evening.
BBC deputy royal correspondent Sarah Campbell
The Duke of Edinburgh drove the Queen into the Castle grounds to meet the president and first lady as they disembarked from their helicopter.
After a quick chat, there was some discussion over where people should sit, with Mr Obama opting for the front seat.
Prince Philip, aged 94, returned to the wheel.
This is the third time the couples have met and the first time in the historic surrounds of Windsor Castle.
Their last meeting was during a visit in 2011 when the Obamas stayed in Buckingham Palace.
In 2009, in what was taken to be a sign of a friendly relationship between the families, the first lady was photographed with her arm around the Queen’s waist.
In their meetings since, including today, there does seem to be a genuine warmth between the two families.
Today’s lunch is private. To the frustration of the many journalists covering this visit, whatever the Queen makes of the president’s views on Britain in Europe will remain within the castle walls.
The president’s intervention in the UK’s forthcoming EU referendum on 23 June has been hotly debated and sparked claims of “hypocrisy” from those who want to leave the EU. They claim the US “would never contemplate anything like the EU for itself”.
In an article for the Telegraph, President Obama acknowledged that ultimately the matter was for British voters to decide for themselves.
But he also said: “The outcome of your decision is a matter of deep interest to the United States.
“The tens of thousands of Americans who rest in Europe’s cemeteries are a silent testament to just how intertwined our prosperity and security truly are.”
In response, Mr Cameron tweeted: “The US is one of our closest allies. So it’s important to hear Barack Obama on why we should remain in the EU.”
EU referendum: In depth
But Vote Leave’s Boris Johnson said although he was a “big fan” of Mr Obama, remaining in the EU is “clearly something we have a disagreement on”.
He said: “America’s a proud democracy built on principles of liberty. It is hypocritical for us to be told by America to embroil ourselves ever more deeply in a structure which would be absolutely alien to American traditions.
“I think most Americans would accept that there is something rum about asking us to subordinate our democracy in this way, when America would not dream in a million years of doing likewise.”
Mr Johnson originally criticised Mr Obama in an article in the Sun but has since been criticised for making comments about the president’s “part-Kenyan” ancestry.
UKIP leader Nigel Farage told BBC News Mr Obama’s views on the UK had been shaped by his Kenyan grandfather’s experience of colonial Britain and he bears a grudge against Britain.
What’s wrong with the BBC? This entry passed through the Full-Text RSS service – if this is your content and you’re reading it on someone else’s site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.