Created
December 16, 2017 15:13
-
-
Save sojohnnysaid/9e8ec6e0f5bbb8b50445530437c348fb to your computer and use it in GitHub Desktop.
Example of a basic function in c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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