Egypt's teeming, chaotic capital is falling into ruins, literally.

Two old apartment buildings collapsed recently, killing at least 47 people. They were the fifth and sixth residential buildings to fall dawn in the past year, and Egyptian officials readily acknowledge that there will be more.

So rickety are the buildings of Cairo's old neighborhoods that the local council of Cairo government, or province, has set up an emergency fund of almost $750,000 to build shelters for homeless survivors.

Official estimates of the number of buildings that should be condemned as unsound and dangerous range from 30,000 to half a million. One local newspaper, looking into the latest incidents, quoted a Ministry of Housing official as saying 70 percent of all the buildings in the city were dangerous.

But most of the occupants cannot be relocated because the city's housing shortage is already acute and there is no place for displaced people to go. The occupants of one quaking building who were finally moved out in the face of its imminent collapse last year spent the entire winter living in tents while the authorities tried to find new apartments for them.

In one of the buildings that collapsed, a 100-year-old block of one-room cubicles, the residents had been warned two months earlier that the place was about to give way, but they refused to move out. When the building did collapse, it left gaping fissues in five others on either side. Now they too are considered dangerous.

The Cairo that is beset by this physical disintegration is not the international political and tourist center on the Nile that is familiar to foreigners and upper-class Egyptians. It is jampacked, impoverished and desperately crowded city with one of the highest population densities on earth crammed into decaying buildings that date back to medieval times.

Five years ago, when the population of Greater Cairo was about 6 million, as compared to approximately 9 million today, a report prepared for a consortium of American universities analyzed the city's housing crisis this way:

The problem long ago reached crisis proportions and if, as seems likely, the city's population is somewhere between 12 and 16 million in the year 2000, then the nature of shelter in the Cairo of tomorrow can hardly be imagined.

The former governor of Cairo, Amin Abdel Hafez, said the city was approaching the point where "it could not be run by any means," and that it was urgent to "stop the deterioration."

But population growth continues unchecked, and the government has not approached the target of adding the 50,000 new apartments a year that would be needed just to keep pace with the increase. There seems to be little prospect of improving the lot of those who live in the crumbling buildings of the old quarters, where the population density is 10 times that of New York and sanitation facilities are marginal.

Barring the actual collapse of their homes, however, those people are generally better off than hundreds of thousands of others who have no real housing at all. Some live in the tombs of the "City of the Dead," a vast cemetery on the outskirts of the city.

Others live in the roofs of existing buildings, where they grow vegetables and even raise goats. As one long-time American resident noted, Cairo looks like a modern big city from the ground, but like a rural village from the air.