Chapter 1. Creating a First C++ Program

In This Chapter

  • Organizing your programs into projects

  • Typing code into the code editor

  • Writing a program that writes to the screen

  • Doing basic math

  • Running your program

It's your lucky day. You have decided to learn the most popular programming language on the planet. From the biggest skyscrapers housing huge Fortune-500 companies all the way down to the garages with the self-starting kids grinding out the next generation of software, people are using C++. Yes, there are other languages, but more programmers use C++ than any other language. In this chapter, you start right out writing a C++ program.

For this chapter we use CodeBlocks, a full-featured system for easily creating C++ code — and it's free! You don't need to spend hundreds of dollars to get up and running. Instead, you can install it right from the CD-ROM that came with this book. However, you're not limited to using CodeBlocks. Several other tools are available to you, but in this chapter we suggest working with CodeBlocks because it's easy to use. In fact, you may find you like it so well that you wind up almost neglecting the other tools.

We assume that you have already installed CodeBlocks. If you have not, you can find instructions in Appendix B.

Creating a Project

Creating a computer program is usually a bigger job than you'd want to organize in your head. Program code is saved in files much like the documents in a word processor. But programs often have more than one source-code ...

Get C++ All-In-One 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.