Parameters and Return Types

Functions can take parameters and return values.

int add(int a, int b) {
  return a + b;
}

int result = add(3, 4);
cout << result; // Output: 7

The return type is defined before the function name. Use void if no value is returned.

← PrevNext →