In 1977, a young couple bought a two-bedroom cooperative apartment here on the West Side for the modest price of $41,000. In late 1979, trading upon a rapidly escalating real estate market, they sold it at quadruple their cost -- $167,500 -- and reinvested $225,000 in an elegant Park Avenue co-op. Last week spending another $20,000 to modernize their home, the couple had the apartment appraised. The asking price suggested by a realtor: $560,000.

For New Yorkers, such prices are a source of wonder. After all, the real estate market here wallowed in the doldrums during most of the 1970s. From 1973 through 1977 the average price of a co-op rose less than 20 percent and even declined in some years, depressed in part by gloom over the city's well-publicized struggle to avert bankruptcy.

In 1978, however, prices chalked up a healthy gain, and in the following two years they positively skyrocketed. Powered by buying from foreigners who regard the United States as politically stable and New York's real estate as vastly undervalued, plus the inflation that makes real estate more attractive than competing investments, the average selling price per room jumped to $60,887 last December from $23,815 two years before. The figures are based on a survey by a leading real estate firm, Douglas Elliman-Gibbons and Ives.

Today a 34-room apartment on Fifth Avenue is available for the eye-popping price of $10 million. The old Vincent Astor apartment on East End Avenue was recently offered at $2.35 million, and an art dealer, Ben Heller, set a record for residential property in January when he sold his East 73rd Street town house for $4.3 million.

Said Edward Lee Cave, chairman of Sotheby Parke Bernet's International Realty Corp.: "Manhattan has become an international city. It is no longer just the leading city in New York State or the East Coast. Every language is at home here today."

He pointed out that wealthy foreign clients, who account for about 80 percent of his company's real estate business, are particularly interested in buying cooperative apartments rather than town houses because of the security such apartments offer. In luxury buildings, television monitors are trained on all exits, scores of doormen hover around doorways to screen visitors, and uniformed elevator men deliver residents directly to their doors.

Moreover, these buildings offer their wealthy inhabitants a range of convenient services such as maids, valet dry cleaning and laundry, limousines and catering.

Despite the condominium craze that has swept other parts of the United States, New York remains decidedly partial to co-ops. Rather than own a specific unit, co-op dwellers purchase shares in an apartment building corporation that entitles them to live in a specific apartment. They pay monthly maintenance charges to cover the building's taxes and interest on the mortgage as well as heat and other services.

The owner's shares appreciate in value as general real estate values increase or as he makes improvements in his apartment. The owner retains the right to sell his shares to any buyer who has the approval of the board of directors.

On the densely populated island of Manhattan, cooperatives occupy virtually all the best locations. The board of directors that run co-ops scrutinize potential new buyers closely and often reject such "undesirables" as entertainers, politicians, bachelors or divorcees. Gloria Vanderbilt and former President Richard M. Nixon, for example, have been turned down by snooty buildings.

Because other co-op owners must absorb any maintenance costs that go unpaid, the boards also examine financial records of applicants closely. One result: In today's tight market, more than 70 percent of sales are being completed for all cash.

Says Sotheby's Cave: "If a client needs financing, I don't even bother to show him our listings."

Thus the high mortgage rates that have put a damper on house sales in other parts of the country have barely dented New York's steep ascent. The only part of the market affected in 1980, according to the Douglas Elliman survey was "moderately priced" apartments, including those selling for under $200,000. Sales in that range declined by 20 percent to 25 percent last year. $2

Buyers of these lower-priced homes usually are allowed to finance them. But the boards nevertheless lay down such terms as a minimum of 50 percent to 75 percent cash down payment.

The result of Manhattan's exploding prices and rigid financing terms is obvious. Laurance Kaiser IV, vice president of Key Ventures, a real estate company, said: "New York is finished for the middle class."

For example, a couple that recently moved from Los Angeles to New York with $100,000 in equity and a 10 percent financing commitment were unable to afford a co-op in the city comparable to the condominium they had left in Los Angeles. Like many other two-paycheck couples earning sizable salaries, they were forced to the suburbs.

Another factor pushing people out of the city is the high monthly maintenance that must be added to any co-op mortgate payments. According to Douglas Elliman's survey, the average annual maintenance per room climbed last December to about $1,900.

Despite the astronomical prices and refusal of many buildings to finance, demand for elegant co-ops continues to far outstrip supply. And real estate agents are predicting even higher prices for 1981.