Comcast Corp. reported a profit of $262 million for the second quarter after losing money a year earlier, as customers continued to add new digital services to their traditional television packages.

The nation's largest cable company benefited from the popularity of digital cable packages, which offer subscribers hundreds of channels at higher costs. Comcast reported that it added 1.1 million digital subscribers during the last year, leading to a 20.5 percent hike in related revenue. The company did not provide revenue numbers for its digital tier customers.

Total revenue in the second quarter was $5.07 billion, up from $4.59 billion in the same quarter last year. Revenue from its cable division was $4.84 billion, up 10.4 percent. The profit came to 12 cents per share, compared with the loss of $22 million (4 cents) in the same period last year.

One hole in Comcast's otherwise upbeat second quarter was a slight decline during the period in the number of basic cable subscribers. The company lost approximately 96,000 basic subscribers, or less than 1 percent of its 21.5 million subscriber base.

The company attributed the losses to normal seasonal churn, including cancellations by college students at the end of the school year and by so-called snowbirds returning north for the summer after spending the winter in the South. Several cable companies have reported similar declines in the second quarter in past years, only to report increases in the third and fourth quarters.

But the decline caught the attention of Wall Street, where investors have been concerned about competition from satellite companies, which in the past several years have been adding customers while the total cable subscriber base has remained relatively stagnant. Comcast's subscriber base, for instance, is essentially unchanged from a year ago.

Comcast shares fell 4 percent, or $1.18, to close at $27.56.

Matthew J. Harrigan, an analyst with Janco Partners Inc., said yesterday that the market may have been overreacting to the basic subscriber decline. "I don't think it was a terrible number. It could have been a little bit better," Harrigan said.

The company says it is still planning to end the year with more subscribers than it had at the beginning of the year, but slightly less than the 100,000 customers it initially told Wall Street it would add.

"We expect to gain subscribers in the second half and gain subscribers for the full year," said Comcast Chief Operating Officer Stephen B. Burke during a conference call with financial analysts yesterday.

Comcast also disappointed some analysts, including Harrigan, by saying it added 327,000 high-speed Internet customers during the last three months. Harrigan had estimated that the company would add 350,000. Comcast is the nation's largest high-speed Internet provider, with more than 6 million subscribers. Revenue from its high-speed service jumped almost 40 percent compared with the same period last year, to $763 million.

Comcast officials said yesterday that they have begun to reap the benefits of their 2002 acquisition of AT&T Broadband, which transformed Comcast into the nation's largest cable operator.

Comcast has negotiated new contracts with cable networks such as ESPN and HBO that have curtailed the steady increases in programming costs. Burke told analysts yesterday that he is planning for a 5 percent increase in programming costs this year, down from about 10 percent hikes in previous years. In coming years, Burke said he plans to bring programming cost increases in line with the rate of inflation.

Comcast swung from a $22 million loss in last year's second quarter to a profit of $262 million in the same period this year.