OneBite.Dev - Coding blog in a bite size

declare a function with return value in C

Code snippet on how to declare a function with return value in C

int multiplyTwoNumbers(int x, int y) {
  return x * y;
}

This code is a sample of a function with a return value in C. The function is named “multiplyTwoNumbers”. It expects two parameters, an “int x” and an “int y”. Then the function performs a calculation of “x * y”, and returns the result as an “int”. The return statement essentially “exits” the function and provides the result of the calculation outside the function. The returned value can then be used in other parts of the code.

c