O'Reilly logo

Sams Teach Yourself C++ in One Hour a Day, Eighth Edition by Siddhartha Rao

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

Lesson 7. Organizing Code with Functions

So far in this book you have seen simple programs where all programming effort is contained in main(). This works well for really small programs and applications. The larger and more complex your program gets, the longer the contents of main() become, unless you choose to structure your program using functions.

Functions give you a way to compartmentalize and organize your program’s execution logic. They enable you to split the contents of your application into logical blocks that are invoked sequentially.

A function is hence a subprogram that optionally takes parameters and returns a value, and it needs to be invoked to perform its task. In this lesson you learn

The need for programming functions

Function ...

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