Search⌘ K

Prompting AI as Your Coding Buddy

Practice asking an AI for C++ code, refine prompts to shape the output, and use it to explore, compare, and debug.

What is prompting?

Learning C++ isn’t something you do alone. You’ve got a partner: an AI that can write code, explain concepts, and help you debug when things go wrong.

But just like learning a new language, how you ask matters. Think of prompting as giving instructions to a very fast, patient helper.

By the end of this lesson, you’ll know how to:

  • Ask the AI for code.

  • Refine your request.

  • Use the AI to explore and experiment, rather than simply copying answers.

First prompt

Try asking the AI:

Write C++ code that prints 2 + 3 on the screen.

Powered by AI
5 Prompts Remaining
Prompt AI WidgetOur tool is designed to help you to understand concepts and ask any follow up questions. Ask a question to get started.
AI buddy

You’ll get a small snippet of code. Run it. That’s somewhat similar to what you created in the previous lesson, but now the AI did what you wanted to do.

C++
// Add your code here

Food for thought:

  • What did the AI give you?

  • Was it exactly what you asked for?

  • Did it add extras (like comments or explanations)?

Refining your prompt

Now, tweak your request (In the same AI buddy widget where you prompted earlier):

Change it to print the result of 2 + 3, not just the text.

Run it. Did the code change? Did it match your expectations?

If not, adjust your words. Try:

Make it print the result with a message: The answer for 2+3 is 5.

Notice how adding or changing just a few words makes the AI adapt.

Why this matters to you

As you move through this course, you’ll:

  • Write your own code first.

  • Then use prompting as a learning supplement: to compare, to experiment, or to get unstuck.

Now you’ve learned how to talk to your coding buddy.

  • Next, we will return to C++ fundamentals with your very first building block: Outputs and Strings.

  • In each chapter, you will build a cool new project in C++.