Build a program with AI
Direct a model to write C++ — and review the memory and type choices it makes on your behalf.
A small program produced under your direction.
Why C++ output needs sharper review than scripting languages, the prompt, and what to check.
Prerequisites
A coding assistant. A C++ compiler to run it, or read along.
What you must understand to judge it
- Types are explicit and fixed; a model picking int where it needs size_t or double is a real bug, not a style nit.
- Prefer the standard library (std::vector, std::string) over manual new/delete — ask for it.
- Every program enters at int main(); compile-then-run is the loop.
The prompt
Write a C++ program that prints the squares of 1 through 5. Constraints:- Modern C++ (C++17). Use the standard library, no manual memory management.- A function square(int n) returning int.- Range-based for loop over a std::vector.- Compiles clean with -Wall -Wextra. Output a single main.cpp and the command to compile and run it.Review what it writes
Review rubric
Tutorial
Learn the basics directly
The Learn tab writes the program by hand. Come here to direct it.
Concepts covered · 1
More like this
Make a page respond: a click counter
A page becomes alive the moment JavaScript listens for an event and changes the page in response. Build a counter, then open it in /code.
Build interaction with AI
The vibe-coder path for JS events: the event→state→render loop you must hold in your head, the prompt, and the review.
Build a script with AI
The vibe-coder path for Python: the shape of a small program, the prompt, and the edge cases AI forgets.
Liked this one?
Pass it on
Discussion
Be the first to ask
Your questions stay private with the team. We can pin answers to share with everyone.
Sign in to ask a question privately on this tutorial.
Sign inNo pinned answers yet for this tutorial.