Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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