Chapter 3. Writing Your First Program

In This Chapter

  • Entering your first C++ program

  • Compiling and executing your program

  • Examining some things that could go wrong

  • Executing your program

  • Reviewing how the program works

This chapter will guide you through the creation of your first program in C++. You will be using the Code::Blocks C++ environment. It will all be a bit "cookbookish" since this is your first time. I explain all of 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. Soon 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

    Creating a New Project
  2. Select Console Applications and select Go (or double-click on the Console Applications icon).

  3. Select C++ as your language of choice and select Next.

  4. Enter Conversion as the Project Title.

    If you followed the steps in Chapter 2, the "Folder to create project in" should already be set to Beginning_Programming-CPP. If not, it's not too late to click the ... button and create the folder in the root of your working disk. (This is described in detail in Chapter 2.) The Code::Blocks Wizard fills in the name of the Project and the name of the ...

Get Beginning Programming with C++ For Dummies® 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.