The Army finally got its chance yesterday to show off for the commander in chief - but at a cost.

It took a year and a half and lipbiting Army patience while President Carter first examined such other exotic tools of war as a Navy nuclear submarine and aircraft carrier, the Air Force's "Doomsday plane" flying command center and the underground headquarters of the Strategic Air Command.

But yesterday, on a hot and dusty plain in central Texas, the Army displayed its might, firing more than 31,000 shells from everything from M60 tanks down to M16 rifles as the president watched from the protection of a covered reviewing stand on a nearby bluff known as Blackwell Mountain.

The whole show cost, depending on which estimate is accepted, more than $2 million or slightly less than $1 million.

Carter's visit here, to the largest U.S. Army base in the world, was one in his series of inspections of American military forces, designed, he has said, to familiarize himself with the nation's military capabilities.

Unfortunately, for the Army, its big chance yesterday, while militarily successful - simulated objective Spur was "taken" - turned into something of a public-relations nightmare because of the cost.

It fell to Maj. Bob Good, the Fort Hood public information chief, to make the best of it as he was surrounded by reporters just before Carter's arrival.

The final "bottom-line" Army estimate of the cost of the exercise, he said, was $950,000 or a little more, not counting whatever it cost the Air Force to send several fighter planes here to provide covering fire for the Army troops. That included the cost of the ammunition, moving the troops, even the rehearsals the Army went through to assure there would be no slip-ups before the president, he said.

But, Good was reminded, as late as Thursday, Brig. Gen. Robert B. Solomon, the Army's chief of public affairs in Washington, was using the $2 million figure as his estimate.

Solomon, Good replied, was wrong and was working from earlier planning estimates before the size of the exercise was scaled back, in part because of cost considerations.

Much was made of the cost estimates here, in part because Carter in recent weeks has been taking an extremely hard line on inflation, denouncing government spending and waste and calling for across-the-board sacrifice to gain control of inflation.

Yesterday morning, at his last stop before flying to Fort Hood, the president delivered what has become his standard anti-inflation message.

"Government spending is something we must attack right now on many different points," he said in front of the federal building in Beaumont, which, as part of the ceremonies, was named after Rep. Jack Brooks (D-Tex.).

"We simply spending too much money in the federal government more than we take in in taxes," he continued. "We have got to cut down the federal budget and I am determined to do so."

White House officials were not amused when asked about the contrast between the cost of the Fort Hood exercise and the Beaumont address.

Press secretary Jody Powell said, "It . . . didn't cost as much as we thought," though he did not supply his own cost estimate.

The president seemed unfazed by the cost controversy, defending the exercise as valuable for his "education" as commander in chief. "Whatever expenditure of funds was involved was well worth it," he said.

Moreover, Army officials argued that the money would be spent anyway training troops here, although not all at once.

What ever the cost, it was clearly the most expensive military operation Carter has witnessed as president and one of the largest such exercises undertaken at Fort Hood. Good said the president witnessed the closest thing to real combat he could "without getting shot at."

As the president, Defense Secretary Harold Brown, Army Secretary Clifford Alexander and other dignitaries watched from the reviewing stand, dozens of tanks artillery vehicles, helicopters and jet fighters poured thousands of rounds of shells, rockets and machine-gun fire into the target, a bluff across the plain known as Lone Mountain.

Carter's visit to Fort Hood was his last stop on a two-day swing through Texas that blended politics with official business.

But yesterday, before several thousand people in Beaumont, Carter heaped praise on Brooks as the 44-year-old post office and federal office building was named after the Texas congressman.