C++ Functions

Use the following template for a C++ function:

// Function to add two numbers
int add(int a, int b) {
  return a + b;
}

Explanation: - int: This specifies the return type of the function, which is an integer. - add: This is the name of the function. - (int a, int b): These are the parameters of the function. In this case, the function takes two integer parameters named a and b. - {}: This is the body of the function, where the actual implementation of the function's logic goes. - return a + b;: This line is the return statement, where the function returns the sum of the two parameters a and b.