The carriage was pulled into the museum by Bittern, the sister engine of Mallard, which marked 75 years as the world's fastest steam train earlier this month.

As he alighted, he spoke to well-wishers who had turned out to welcome him.

Among them was Sam Dalby, a student at St Wilfrid's RC Primary School in York.

Sam said: "I asked him 'Do you like trains?' and he said he'd liked them since he was a boy."

Charles blew the whistle of the Doncaster-built Mallard, which broke the world record for steam when it nudged 126mph on the East Coast Main Line in July 1938 and is a permanent exhibit at the museum.

He also met retired Mallard driver Bernard Bell, 89, who once transported the Queen on a royal visit when he was working as a fireman on another locomotive.

Mr Bell, from York, who drove Mallard, Bittern and similar engines for decades, said: "He was very interested in the locomotives and he asked me all sorts of questions about my driving.

"It's the first time I've met him and he seemed very nice."

The Prince also spoke to Tobias Lumb, the National Railway Museum's project manager, who worked on the celebrations for Mallard's anniversary.

"He seemed really interested about what the museum was doing," Mr Lumb said.

Charles also looked round the museum's collection of royal carriages, including Queen Victoria's favourite carriage, King Edward's saloon and Queen Elizabeth's saloon, used by the Royal Family during the Second World War.

The visit is the first event of the tour of Yorkshire by the Prince, who will be joined by the Duchess of Cornwall on Tuesday when he will visit rural communities before ending up in the seaside town of Bridlington.

As worldwide interest in the impending new addition to his family focused on St Mary's Hospital in central London, Alex Dickinson and her sons, Thomas, seven, and Freddie, five, travelled from nearby Church Fenton to catch a glimpse of Charles.

Ms Dickinson wished him well with the birth of his grandchild as her children gave him a picture of a giraffe for the baby.

"He said 'Thank you very much'," she said.

"Freddie said he thought the baby was coming in six hours and Charles said 'Yes, it may well be'."

Thomas said: "He didn't say anything about if it was a boy or a girl."

Asked by another bystander whether there was any news from the hospital, the Prince replied: "Absolutely nothing at the moment - we're waiting."

Charles was greeted by cheering crowds and the Archbishop of York, Dr John Sentamu, when he arrived at York Minster.

He walked through the magnificent interior of the Gothic cathedral with the Archbishop as stunned tourists stopped to take photographs.

The Prince stopped to talk to some of the visitors, all of whom said later that they forgot to ask him about the impending royal birth.

He was given a private tour of a recently opened state-of-the-art visitor attraction, Revealing York Minster, in the Undercroft before moving on to the workshops to talk to the craftsmen and apprentices restoring the building.

Charles even had a go with a chisel and a hammer as he talked to the stonemasons.

He then took great interest in the work of the York Glaziers Trust, which is currently conserving and restoring each of the 311 panels in the Minster's Great East Window - the largest expanse of medieval stained glass in the UK and one of the most important in the world.

The Dean of York, the Very Reverend Vivienne Faull, said: "We're proud and excited that he's come today - but especially today because, in the life of his family, this is going to be such an important day."

The Dean said she was especially pleased the Prince took such an interest in the apprentices working at the Minster.

As the Prince left the workshops, in glorious sunshine, he was greeted by crowds shouting "congratulations".