Stocks rose Tuesday for the second-consecutive day after a flurry of better-than-expected earnings reports.

The Dow Jones Industrial Average rose 341.67 points, or 1.13%, to 30,527.49. The S&P 500 rose 42.55 points, or 1.16%, to 3,720.50, and the Nasdaq Composite gained 96.60 points, or 0.90%, to 10,772.40.

All three indexes traded higher in early trading but gave back most of the day's gains after Treasury bond yields rose. The hot start to the week helped reverse sustained market declines amid investor uncertainty over inflation and the Federal Reserve's efforts to combat it with interest rate hikes.

The central bank is expected to raise interest rates for the sixth time this year when Fed officials meet next month.

Goldman Sachs (GS) reported a smaller-than-expected decline in profits and a corporate reorganization and its share price rose $7.54, or 2.46%, to close at $314.25.

Shares of Lockheed Martin (LMT) surged after the defense contractor's earnings exceeded analysts' expectations. Lockheed's share price jumped $35.01, or 8.81%, to close at $432.32.

Other stocks that reported gains included Uber (UBER), which closed at $27.61, up $1.67, or 6.46%. Target's (TGT) price of shares rose $8.11, or 5.43%, to close at $157.36.

"Great that we have some buyers stepping in. I think getting some flow and some sustainability, or at least some support, in this market is really important and we will take it. But we do not think we are out of the woods yet," Alli McCartney, UBS Private Wealth Management analyst, told CNBC.