Functions Summary

In this chapter, we learned to work with functions in C++. We discovered that:

  1. We use functions when we want to group repetitive code or solve a specific problem.
  2. We define a function by specifying the return type, followed by the function name and parentheses.
  3. Every function must have a specified return type (e.g., void for functions that don't return anything).
  4. The function body contains the code that executes when the function is called, enclosed in curly braces.
  5. We call a function using its name followed by parentheses.
  6. We can only call a function after its declaration.
  7. Functions can accept parameters that influence their behavior.
  8. For each parameter, we must specify its data type.
  9. Function parameters can have default values, which are used if no parameter value is provided when calling the function.
  10. Functions can return values using the return keyword. The returned value must match the declared return type.
  11. Every C++ program must contain a main function that returns int.

Instructions

Congratulations on completing the C++ course! Now just practice and combine the concepts you've learned and you'll be surprised what you can program!

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

7/7

Functions Summary | Start Coder