U.S. stocks closed higher on Tuesday following positive earnings from top-tier companies and as investors were focused on quarterly results from Magnificent Seven and other megacap growth stocks.

Tesla kicked off the earnings cycle for technology heavyweights after markets closed on Tuesday, announcing the launch of new electric vehicle models and quarterly revenue that missed analyst estimates. Its shares jumped 6% in extended hours trading.

That will be followed by results from other tech majors, including Microsoft, Alphabet, and Meta Platforms, later this week.

Markets were also buoyed by upbeat earnings from companies such as General Motors, which closed up 4.4% after the automaker's better-than-expected quarterly results.

Ten out of 11 S&P 500 sectors were advancing led by gains in equities in communication services and technology sectors. The S&P Materials sector ended lower dragged by steelmaker Nucor Corp, which lost ground by 8.9% after a first-quarter earnings miss. "We're having a continuation of an oversold balance that started yesterday and the catalyst today is that markets are now refocused on earnings reports across a wide array of sectors that were strong," said Keith Lerner, co-chief investment officer at Truist Advisory Services in Atlanta.

The Dow Jones Industrial Average rose 263.71 points, or 0.69%, to 38,503.69, the S&P 500 gained 59.95 points, or 1.20%, to 5,070.55 and the Nasdaq Composite gained 245.34 points, or 1.59%, to 15,696.64.

Data on Tuesday showed that U.S. business activity cooled in April to a four-month low due to weaker demand, while rates of inflation eased slightly even as input prices rose sharply, suggesting possible relief ahead for rising consumer prices.

Investors will be eyeing the release of the March Personal Consumption Expenditures (PCE) index - the Federal Reserve's preferred inflation gauge - which is due on Friday.

Money markets are now pricing in just about 43 basis points of interest-rate cuts, down from about 150 bps seen at the start of the year, according to LSEG data.

"The PMI report was a little bit weaker and the employment was a little bit weaker and the market at this point is taking that is a bad-news-there-is-good-news, meaning the people are becoming too hawkish on Fed expectations," Lerner added.

Spotify rose 11.4% after the Swedish music streaming giant posted gross profit that topped 1 billion euros ($1.1 billion) for the first time.

Bullish full-year profit forecast helped to lift GE Aerospace shares by 8.3%. Danaher gained 7.2% after the life sciences firm beat quarterly profit and sales expectations.

Shares of JetBlue plunged nearly 19% as the low-cost carrier trimmed its annual revenue forecast following lukewarm first-quarter revenue.

Advancing issues outnumbered decliners by a 4.89-to-1 ratio on the NYSE. There were 86 new highs and 30 new lows on the NYSE. On the Nasdaq, 3,051 stocks rose and 1,135 fell as advancing issues outnumbered decliners by a 2.69-to-1 ratio.

The S&P 500 posted 12 new 52-week highs and 2 new lows while the Nasdaq recorded 57 new highs and 85 new lows.

Volume on U.S. exchanges was 10.57 billion shares, compared with the 11.07 billion average for the last 20 days. (Reporting Chibuike Oguh in New York; additional reporting by Shristi Achar A and Shashwat Chauhan in Bengaluru; Editing by Aurora Ellis)