Chapter 3

Writing Your First Program

In This Chapter

arrow Entering your first C++ program

arrow Compiling and executing your program

arrow Examining some things that could go wrong

arrow Executing your program

arrow Reviewing how the program works

This chapter guides you through the creation of your first program in C++, using the Code::Blocks C++ environment. It’s a bit “cookbookish” because I assume this is your first time programming in C++. I explain all the parts that make up this program in subsequent chapters (beginning with Part II), but for now, you’ll be asked to accept a few things on faith. After you’ve had a chance to see it all work together once, all will be revealed — and everything you do in this chapter will make perfect sense.

Creating a New Project

As always, you must create a new project to house your program. Follow the abbreviated steps here (or you can use the detailed steps from Chapter 2):

  1. With Code::Blocks open, select File⇒New⇒Project.
  2. Select Console Applications and select Go (or ...

Get Beginning Programming with C++ For Dummies, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.