OneBite.Dev - Coding blog in a bite size

declare a function with single parameter in C

Code snippet on how to declare a function with single parameter in C

  int add(int x)
  {
    int result = x + 1;
    return result;
  }

This code declares a function named “add” which accepts a single parameter of type integer (int x). The function then adds “1” to the given integer and stores the result into a new variable called “result”. Finally, the function returns the value of “result” to the calling code. By doing so, it gives the calling code access to the result of the addition.

c