The Ultimate Guide to C++ for Kids & Teens

iD Tech in action

C++ might be considered any programmer’s bread and butter. Not only is it a must have for app developers and software, learning C++ will unlock the secrets of the vast coding universe! 

From there, early coders will be on their way to some of the best STEM careers out there and opening doors to creating video games, the latest app, and so much more.

In this introductory guide to C++, we’ll take a look at some key terminology, useful programs, and a few example project ideas for inspiration. 

Visual Studio

The software beginners can use to program in C++ is called Visual Studio. It’s an industry-wide platform with many tools and features to help! First things first— kids will need to know how to create a new program and what some of its windows represent.

So, let's walk through it! Here are a few important terms to know first: 

Visual Studio organizes programs into solutions, projects, and files.

Projects are sets of files that share the same resources. When creating a new project, Visual Studio also created a solution for it.

Solutions are full sets of projects and files that make up a program. Generally, a solution will have only one project in it.

A variable is a container that holds a single number, word, or other information that you can use throughout a program.

Files are the individual pieces that make up programs. 

Main Function

The main function is where the bulk of the code will go. For a program to run, it must have a main function. Visual Studio starts a program with code that looks like this:

All the code that the main function runs goes between an opening curly bracket { and a closing curly bracket }

Building your solution tells the IDE to test for errors and compile the code. Compiling converts your code from C++ to complex machine code that the computer can run.

Variable names

Understanding variables and how they work is critical to C++. A variable is like a chest or a container that can be filled with different values. The containers are names so they can be found later.

When a type of variable is specified, like a string, doing so tells the program that this chest can only be filled with words, phrases, and multiple characters. It won't be able to hold numbers, true/false values, and so on. 

Variable types

There are many kinds of variables that can be used to represent names, ages, and other information in a program.

String

A string represents text; words and phrases. Said differently, it’s a sequence of characters enclosed in double quotation marks:

string jimmysName = "Jimmy"; 
string twoWords = "Hi there!"; 
string nonsense = "sdfg sdf ksksjs"; 

In terms of assigning values to variables, a value is the information the variable holds. So, with the sting, it’s a word. As mentioned above, assigning values to variables is like filling a chest with something. When the variable myName is used , the computer will return the value inside it.

To change a variable, simply write the variable name and a string value. Whatever value was written before will now be overwritten by the new value. 

And when naming variables, it’s suggested to do so descriptively so coders can remember what is placed in each. 

Other variable types include: 

Char

A char is a single letter or symbol you can type, enclosed in single quotation marks.

char a = 'a'; 
char exclamation = '!'; 

Int

Int is short for integer, which is a whole number.

int myAge = 94; 
int myCats = 300000000; 

Double

Doubles and floats are numbers with a decimal. A double is more precise than a float; it can hold more numbers before and after the decimal.

double decimalNumber = 4.4567; 
double pi = 3.14159265; 

Bool

Bool is short for boolean. It represents a value that's true or false.

bool iAmAnAlien = true; 
bool aHungryAlien = false; 

Arithmetic operators

Arithmetic operators are crucial to games. For example, when players endure damage or earn experience points, totals need to be calculated in some fashion. 

C++ arithmetic operators read from left to right and follow the normal mathematical order of operations. Some basic operators and their order of precedence are listed in the table below.

Arithmetic operators can be performed on both variables and literals (data typed in directly).

Example Games

There are a wealth of options in terms of games that can be coded with C++. Here are just a few examples to get coders thinking about what they might want to create!

RPG Fighting Tournament

This type of game includes creating, saving, and loading characters, tracking a character's wins in their save file, and individual character stats. In these games, turn-based combat is in a loop that determines the winner and moves the player through various levels or objectives. If that sounds familiar, it should to most gamers—many big-name video games follow this format!

Pong

Pong: a true gaming icon and one of the earliest arcade games. Using a couple UI elements in SFML, a simple single-player Pong game can be created.

Tetris

Tetris is a classic puzzle game where you try to position falling blocks to create lines without building over the top of the board. Tetris has some interesting programming challenges involved in creating it.

Checkers

Creating a new game from scratch can seem like a daunting task. However, with good planning, you can break a project into smaller pieces. (Stay tuned for a tutorial on how to create your own checkers game with C++! 

Unlock a World of Possibilities

Learning to code with C++ involves so many processes and concepts that are central to coding in any language. Think of practicing these basics as a skeleton key for more programming adventures to come!

If that sounds like just the springboard needed to dive into programming, expert guidance can help take the plunge! Check out C++ tutoring for personalized instruction in this exciting coding language.  

A photo of Virginia

Virginia started with iD Tech at the University of Denver in 2015 and has loved every minute since then! A former teacher by trade, she has a master's in education and loves working to embolden the next generation through STEM. Outside the office, you can usually find her reading a good book, struggling on a yoga mat, or exploring the Rocky Mountains. 

Featured Posts

Categories

Authors

About iD Tech

iD Tech is the #1 tech camp on the planet, and world leader in youth STEM education, with programs held online and at 150+ global locations offering 50+ innovative tech courses: 

Coding camps
Video game camps
Robotics classes & camps
Creative arts classes & camps

We've bet our reputation on recruiting the top instructors in the country. Our small classes ensure customized learning, leading to "a-ha moments" and awesome outcomes. Programs include:

On-Campus Programs

Online Tutoring

All Coding Courses