C Function Basics
The basics of prototyping (declaring) implementing (defining) and calling (using) functions in C.
FunctionBasics.c
#include <stdio.h>
#include <stdlib.h>
//function prototype
void printGreeting();
//function prototype
float avg(float v1, float v2);
int main(void) {
printGreeting();
float someNum = avg(10,20);
printf("someNum = %f\n", someNum);
return 0;
}
// implementation - defines the function's actions
void printGreeting() {
printf("Hi!\n");
printf("Hello!\n");
}
// implementation - defines the function's actions
float avg(float v1, float v2){
float average = (v1 + v2) / 2.0;
return average;
}