E.C. Ernst Inc., the 67-year-old electrical construction firm that has been rising from the ashes of near-bankruptcy for the past four years, yesterday reported its first quarterly operating profits since the end of 1977.

Washington-based Ernst said earnings from operations for the three months ended Sept. 30 were $172,000 compared with a loss of $1.2 million in the same period last year as contract revenues fell to $12.7 million from $13.8 million. The recent quarter's gains overcame a $62,000 first-quarter operating loss and resulted in a profit from operations for the first six months of the company's fiscal year: $110,000 vs. a loss of $2.8 million in the similar 1980 period.

Ernst had net income of $2.16 million (60 cents a share) for the recent quarter compared with a net loss of $1.38 million a year earlier; the six-month net income was $5.97 million ($1.67) vs. $13.59 million ($3.80) last year. However, Chairman Joseph Griffin noted, the total net income includes nonrecurring claims income. Six-month contract volume was $23.8 million compared with $26.1 million a year earlier.

"Rebuilding the backlog of contracts with new major contracts and maintaining tight controls over direct costs and overhead remain the keys to profitability . . . it is essential that the company do even better," Griffin stated.

About $7.5 million in cash has been received in the current fiscal year from settlements of claims and lawsuits, he added. Of this amount, $5 million was used to repay funds previously advanced to the firm and $2.5 million was retained to fund the prospective emergence from a Chapter XI bankruptcy proceeding filed in 1978 and under which the firm has been reorganizing its debts since.

Improved earnings also were reported by C3 Inc., the Reston microcomputer company. Profits for the second quarter, ended Sept. 30, climbed to $2 million (23 cents) from $1.1 million (16 cents) in the same period a year ago, as revenues jumped to $11.3 million from $7.3 million.

For the first half of its fiscal year, C3 earned $3.8 million (44 cents) on revenues of $21.9 million, compared with profits of $2.2 million (31 cents) on revenues of $14 million in the first half of 1980.

Electronic Modules Corp. of Timonium posted an annual profit of $2.1 million ($1.01) on sales of $32.8 million for the year ended Sept. 26, up from earnings of $1.5 million (75 cents) on sales of $22.3 million. The firm manufactures high-technology devices.

Richmond, Fredericksburg and Potomac Railroad Co. reported third-quarter earnings of $3.7 million ($10.34), a 35 percent increase from the $2.75 million ($7.67) earned in the third quarter of last year. Operating revenues for the quarter were $13.3 million, an increase of $1.5 million, or 13 percent, from the same period last year.

While carload traffic remained static for both quarters, the revenue improvement was attributed to higher average revenue per car because of rate adjustments and a change in the mix of total traffic handled. RF&P President John Newbauer noted that third-quarter earnings in 1980 were adversely affected by a nonrecurring write-off of Auto-Train prebankruptcy receivables.

For the first nine months of 1981, earnings were $12.13 million ($33.77) on total operating revenues of $40.9 million. This compared with earnings last year of $11.17 million ($31.16) on revenues of $36.7 million.