O'Reilly logo

C++ All-in-One For Dummies, 3rd Edition by John Paul Mueller, Jeff Cogswell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5

Dividing Your Work with Functions

In This Chapter

arrow Calling a function

arrow Passing things, such as variables

arrow Writing your own great functions

arrow Fun with strings

arrow Manipulating main()

People generally agree that most projects throughout life are easier when you divide them into smaller, more manageable tasks. That’s also the case with computer programming — if you break your code into smaller pieces, it becomes more manageable.

C++ provides many ways to divide code into smaller portions. One way is through the use of what are called functions. A function is a set of lines of code that performs a particular job.

In this chapter, we show you what functions are and how you can use them to make your programming job easier.

Dividing Your Work

If you have a big job to do that doesn’t involve a computer, you can divide your work in many ways. Over the years of studying process management, people have pretty much narrowed the division of a job to two ways: using nouns and using verbs.

Yes, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required