Now that you’ve learned about some of the pieces of a C++ program, you can answer a couple of questions and complete a couple of exercises to firm up your knowledge.
What data type does the main function return?
It does not return a type.
What do the braces do in a C++ program?
Indicate the start and end of a function
Indicate the start and end of a program
Straighten the program’s teeth
What is not part of a function’s signature?
Its return type
The main function returns an int (integer).
Braces mark the start and end of functions and other blocks of code you learn about in upcoming hours.
A function signature consists of its name, parameters, and the precise order of those parameters. It does not include its return type.
Rewrite the Motto program to display the Aarhus University motto in a function.
Rewrite the Calculator program to add a third integer called z in the add() function and call this function with two sets of three numbers.
To see solutions to these activities, visit this book’s website at http://cplusplus.cadenhead.org.