Jeremy Lloyd.

Sitcom writer.

Born: July 22, 1930;

Died: December 22, 2014.

Jeremy Lloyd, who has died aged 84, was, with his writing partner David Croft, responsible for the sitcoms Are You Being Served? and 'Allo 'Allo. There were critics who thought that "responsible" was le mot juste; both shows were entirely formulaic and shamelessly traded on stereotypes, doubles-entendres and innuendo generally. They were open to, and received, accusations of sexism or even misogyny, racism, homophobia, cultural insensitivity and a host of other sins; future generations of liberal critics will probably add more to the charge sheet.

Yet they were incredibly popular. Are You Being Served? ran for 69 episodes and attracted 22 million viewers on its initial broadcasts, and is still repeated almost daily in America, Australia, New Zealand and Canada; 'Allo 'Allo ran for 85 episodes over a decade, despite a year off, and was voted the 13th best sitcom ever by British viewers.

Are You Being Served? was based on Lloyd's brief experience of working in a department store - Simpson's of Piccadilly - and featured Frank Thornton as the patrician shop supervisor, Captain Peacock, Wendy Richard as the leggy assistant Miss Brahms, John Inman as a caricature homosexual with the catchphrase "I'm free!" and Mollie Sugden as Miss Slocombe, a cantankerous spinster with hair dyed in a variety of improbable pastel shades. She was devoted to her cat, and much mileage was made from use of the word "pussy".

'Allo 'Allo was based on a serious BBC drama, Secret Army, which aired between 1977 and 1979, and dealt with the Belgian Resistance helping stranded British airmen to escape occupied Europe. By contrast, Lloyd and Croft, and from 1991-92 Lloyd and Paul Adam, based their programme in a French café whose proprietor René Artois (Gorden Kaye) mainly found the occupying Nazis - the pompous Colonel von Strohm, the stereotypically homosexual Lieutenant Gruber and the stereotypically sinister Gestapo officer Herr Flick - an impediment to an easy life and a string of affairs. The poor French of the British airmen was an excuse for a series of abysmal puns.

John Jeremy Lloyd was born on July 22 1930 at Danbury in Essex, the son of an army colonel and a Tiller girl who parted soon after his birth. He was brought up at first by his grandmother in Didsbury, Manchester, and later at boarding school and an old folks' home. He was known at school as "Beaky", because of his prominent nose, which later provided him with the material for Captain Beaky and his band.

This stage show, featuring the eponymous leader and a host of animal sidekicks such as Hissing Sid, proved successful, and even led to a top ten single, with music by Jim Parker.

After leaving school, Lloyd worked in a series of jobs - road-digger, plumber's mate, light bulb inspector, the job at Simpson's and paint salesman - before trying his hand at writing. His first script, completely rewritten by Terry Nation, was for the film What a Whopper (1961), a yarn about the Loch Ness monster which starred Adam Faith. Thereafter he wrote sketch material for acts such as Morecambe and Wise, Bruce Forsyth and Lionel Blair, and embarked on an acting career of sorts, playing upper class twits.

He had bit parts in such films as School for Scoundrels and Doctor in Clover and appeared in two Beatles movies, A Hard Day's Night and Help! Lloyd was by this time fully immersed in Swinging London, married to Dawn Bailey, a model, and friendly with Terence Stamp, Michael Caine, David Niven and other stars.

After the break-up of his first marriage in 1962, he had a fling with Diana Rigg and became engaged to Charlotte Rampling; in his memoirs, he claimed that he had been due to have dinner with the actress Sharon Tate on the night she and her guests were murdered by the Manson family. He was a well-known man about town, often driving expensive cars (at one point he had a vintage Bentley), on both sides of the Atlantic.

The Hollywood connection came from Lloyd's stint on the American TV show Rowan and Martin's Laugh-In, which featured stars such as Sammy Davis, Jr and Dean Martin. But when he returned to Britain, he embarked on an affair with Joanna Lumley, and in 1970 had to choose between returning to the USA and marrying her.

Understandably enough, he chose the latter course of action. But it was a miscalculation. The marriage lasted just a few months, and Lloyd found himself unemployed and without many prospects. He pitched the idea for Are You Being Served? to ITV, where it languished in development, but after he bumped into David Croft, the co-author of Dad's Army, he reworked it, and it was taken on by the BBC. It was a roaring hit from the off, and Lloyd never looked back.

Besides his two successful sitcoms and the Captain Beaky material, Lloyd wrote a forgettable sequel to Are You Being Served? entitled Grace and Favour, a detective show called Whodunnit (1973), and two further comedies, both written with David Croft.

The first was Come Back Mrs Noah (1977), which starred Mollie Sugden as a housewife blasted into space, and is a strong contender for the worst programme ever aired on British television. The second, about a brass band and called Oh Happy Band (1980) starred Harry Worth, was only a marginal improvement. It ran for six episodes.

In 1992, he married Collette Northrup, an actress. That marriage was also dissolved and earlier this year he married for the fourth time, to the interior designer Elizabeth Moberly. She survives him.