Stock market volatility can be unnerving, but the key to navigating bumpy periods is to own great companies and maintain a laser focus on the long term. The technology-centric Nasdaq-100 index has more than doubled over the last five years, for example, even after accounting for its 28% loss in 2022. A down market can, therefore, be a great time to put available cash to work.

When deciding where to put it to work, it's important to choose companies that are either profitable or that are growing quickly with a strong cash position to provide a clear pathway to profitability. Those features can minimize the risk of a particular company suffering a worst-case scenario during volatile times in the market. 

Here are two stocks that fit the bill, and one that investors should avoid. 

The first stock to buy: Alphabet

Alphabet (GOOG -1.96%) (GOOGL -1.97%) has all the traits of a company investors should want to own in any economic environment, but especially during uncertain times. It's the parent company of Google, which holds a 92% market share in the internet search business, but that's just part of the story.

Alphabet's strength comes from its diversity. It owns a rapidly growing cloud services segment, plus the dominant video platform YouTube, and a hardware business responsible for the popular Pixel smartphone (among other devices). It attracts a healthy mix of individual and business customers which can help the company perform in all conditions; when one business unit is slow, there's always the potential that others will pick up the slack.

Over the last four quarters, Alphabet's combined businesses have generated $270 billion in revenue and $74.5 billion in net income (profit), which translates to $110.56 in earnings per share. Its stock is very attractively priced at just 21.1 times earnings, which is a 16% discount to the Nasdaq-100 which trades at a multiple of 25.2. 

Alphabet is innovative, diverse, profitable, and cheap relative to the broader market. It's hard to go wrong, and as a side note, keep an eye out for its 20-for-1 stock split which kicks in on July 15.

The second stock to buy: C3.ai

Artificial intelligence (AI) might be the most transformative technology of our time. It's already proving its ability to complete complex tasks in a fraction of the time that humans can, and one estimate suggests it could add $13 trillion in value to the global economy by 2030. Unfortunately, developing AI can be extremely complex so it hasn't been widely accessible -- but then C3.ai (AI -0.85%) came along. 

The company builds ready-made, customizable AI applications to fit almost any business case. It currently serves 11 entirely different industries including oil and gas, agriculture, defense, and financial services (to name a few). It highlights C3.ai's adaptability, which is especially impressive because it's effectively pioneering a brand new industry.

C3.ai generated $252.7 million in revenue in fiscal 2022 (ended April 30), which was a 37% increase compared to fiscal 2021. But the company is still in its growth phase and isn't focused on making a profit yet. In fact, it made a net loss of $192 million in fiscal 2022.

But C3.ai does have over $950 million in cash, equivalents, and short-term investments on its balance sheet which can carry it through several more years of similar results. Put simply, it has time to continue investing in growth before pulling back to deliver positive earnings. 

As an investment, C3.ai isn't of the same caliber as Alphabet. It's a riskier play and operates in just one business segment, but its long-term growth potential is undeniable as AI becomes more commonplace. Its opportunity might even be as large as $596 billion by 2025, according to the company's estimates.

The stock to sell: Twitter

Twitter (TWTR) is in the headlines for all the wrong reasons right now. The social media giant was all set to be acquired by the eccentric head of Tesla, Elon Musk, before he recently decided to pull out of the purchase. The deal would've been worth $44 billion, or $54.20 per share, which is far higher than the $33.48 it trades at today.

Reasons aside, this is now likely to end up in court which could shroud the company in months of controversial public discussion about the stock, taking management's focus away from running the actual business.

That's reason enough to stay away from Twitter stock in the near term, but there are also several business challenges the company has to confront. Like all social media platforms, it's facing increased competition and in a slow economic environment, advertisers are far more stringent with their marketing spend. But even before the broader uncertainty arose, Twitter appeared to be on track to miss the ambitious 2023 financial targets it set back in early 2021. 

The company anticipated it would reach $7.5 billion in annual revenue next year, but analysts are now projecting it could fall about $400 million short, hitting $7.1 billion instead. It also sought to grow its monetizable daily active user base to 315 million, but the math isn't quite shaking out, and it could fall millions of users short of that goal, too. 

Twitter does have financial security on its side. It has a very strong balance sheet with over $6 billion in cash, equivalents, and short-term investments. The company is also profitable at the moment, so it's not an absurdly risky investment.

However, its stock is likely to continue to trade solely on Musk-related news for the foreseeable future, and when combined with slower growth and missed targets, there are enough reasons for investors to remain sidelined for now.