Return value

int myFunction(int x) {
  return 5 + x;
}
int main() {
  printf("Result: %d", myFunction(3));
  return 0;
}
// output 8 (5 + 3)

two parameters

int myFunction(int x, int y) {
  return x + y;
}
int main() {
  printf("Result: %d", myFunction(5, 3));
  // store the result in a variable
  int result = myFunction(5, 3);
  printf("Result = %d", result);
  return 0;
}
// result: 8 (5 + 3)
// result = 8 (5 + 3)
Comments