C3 Inc., a Herndon computer systems firm specializing in government work, said yesterday that it had agreed to be taken over for $157.5 million by AGS Computers Inc., a New Jersey company that sells computer products and services primarily to commercial customers.

Under the terms of the merger, AGS will pay C3 shareholders $15.75 in cash for each share they own, making C3 a wholly-owned subsidiary of AGS. The agreement in principle is subject to approval by C3 shareholders and the regulators.

C3's stock rose $2.75 yesterday, to $14.50 a share, following the announcement.

Richard C. Litsinger, chairman of C3, said yesterday that the company agreed to the acquisition by AGS -- a company more than five times the size of C3 -- because it enhances both companies' strategic positions.

"We are certainly good partners, let's put it that way," he said.

Litsinger, who will continue to run C3 in Herndon after the takeover, said AGS brings expertise to C3 in software development and access to a wide variety of microcomputer products that C3 can use in bidding for government contracts.

C3 specializes in putting computer hardware made by different vendors together for government customers.

"AGS's main motivation is {that} they were looking to establish a major presence in the government marketplace and they elected to do it by acquiring what they thought was the leading systems integrator," Litsinger said.

"Their markets and products are very complementary to C3. ... Their market is almost 100 percent commercial, whereas we are almost 100 percent governmental. They bring talents and products to us that we don't have and we bring talents and products to them that they don't have."

Analysts who follow C3 said yesterday that the company was a logical takeover target in light of its recent strong financial performance.

They said its stock price has been undervalued in the wake of a five-year period of scandals that culminated in a plea of guilty to 200 counts of defrauding the government, a $5.4 million fine and the ouster of its two top executives.

Under Litsinger, who took over as top executive of the company two years ago, C3 has made a vibrant recovery, and last year won a $272 million contract to supply computer equipment to the Marine Corps. In the fiscal year ending last March 31, C3 had a profit of $4.2 million on revenue of $86.3 million.

"C3 was subject to a takeover attempt and they probably decided that they preferred to find somebody to their liking," said Thomas Taylor, an analyst with Chesapeake Securities.

Taylor said the merger with AGS would make C3 better able to compete for larger government computer contracts.

"They can bid for bigger contracts and there will be some really large type contracts that are going to be coming up in the future," he said.