Skip to content

Instantly share code, notes, and snippets.

@sojohnnysaid
Created December 16, 2017 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sojohnnysaid/9e8ec6e0f5bbb8b50445530437c348fb to your computer and use it in GitHub Desktop.
Save sojohnnysaid/9e8ec6e0f5bbb8b50445530437c348fb to your computer and use it in GitHub Desktop.
Example of a basic function in c
#include <stdio.h>
// add_two_numbers takes 2 arguments, which are 2 numbers, adds them up and returns the result.
int add_two_numbers(x, y)
{
return x + y;
}
int main(void)
{
int sum;
sum = add_two_numbers(40, 2); // storing the returned result into the sum variable
// using printf which is also a function,
// to display the statment in the terminal window
printf("40 plus 2 is %d\n", sum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment