By Jennifer Maloney

Cheetos and Quaker Oats have sold well during the pandemic. Soda hasn't.

PepsiCo Inc. posted flat revenue for the latest quarter as increased demand for its snacks and packaged foods largely offset a decline in beverage sales. Business improved in May and June as shelter-in-place measures eased, the company said.

PepsiCo's second quarter ended June 13 -- when many states were lifting coronavirus restrictions but before a surge in cases in Florida, Texas and other states prompted some local officials to pause plans to reopen indoor dining, movie theaters and other activities. More than 3 million Americans have tested positive for the virus and more than 135,000 have died.

"This is going to be, you know, a roller coaster," Chief Executive Ramon Laguarta said in a call with analysts Monday.

If people get out more and cook less at home, PepsiCo's beverage sales should improve, while packaged-food brands may decline, the company's finance chief, Hugh Johnston, said in an interview.

The company's namesake sodas and other drinks have been hurt by the closing of many restaurants and people making fewer trips to convenience stores. Revenue at its North American beverage division, the company's biggest contributor, fell 6.6% to $4.97 billion in the quarter ended June 13.

On the flip side, the company's food business has enjoyed a boost from Americans cooking at home and stocking up on familiar grocery brands. In its Frito-Lay North America division, which makes Doritos, Lays potato chips and other snacks, sales rose 6.6% to $4.27 billion.

People working from home "have rediscovered big brands" and returned to old snacking habits, driving double-digit growth in PepsiCo's Cheetos, Tostitos and Fritos brands, Mr. Johnston said. Sales at Quaker Foods North America rose 23% to $664 million.

Taken together and including declines in PepsiCo's international operations, the company reported that its total organic revenue fell 0.3% from a year ago in the second quarter. The company, like rival Coca-Cola Co., had been posting strong gains in organic revenue before the pandemic hit earlier this year.

As have other big consumer-goods companies, PepsiCo has been trimming its offerings to simplify its supply chain during the pandemic and prioritize factory lines for in-demand items.

Coming out of the coronavirus crisis, the company will likely produce 5% to 10% fewer products, Mr. Johnston said.

PepsiCo's packaged-food unit that sells Aunt Jemima products last month said it would retire the brand because of its origins in racist imagery of Black people amid a national reckoning over racial justice following the killing of George Floyd.

The company will retain some of the Aunt Jemima brand's color scheme while changing the logo and name, in an effort to keep consumers loyal to the product, Mr. Johnston said.

"We've done brand transitions before when we've purchased a local brand, say potato chips," he said. "You have to overcommunicate" to the shopper through advertising and shelf tags, he added.

For the fiscal second quarter, total revenue fell 3.1% from the prior year to $15.95 billion. Net income fell to $1.65 billion from $2.04 billion, but on an adjusted basis the results were ahead of Wall Street's expectations.

Dave Sebastian contributed to this article.

Write to Jennifer Maloney at jennifer.maloney@wsj.com