Hi guys, so I'm getting myself really confused with functions and I don't really understand them. I am given a simple task which is:


The following program is supposed to calculate and print the area of a triangle. Finish writing the program. You will need to write the areaOfTriangle() function as part of your solution. Make sure you observe the format of the output. In case you forgot, the formula for area of a triangle is -
Code:
area = 1/2 * base * height


...

int main()
{
    double base, height, area;
    printf("Enter the base and height => ");
    scanf(" ? ? ",&base,&height);

    area = areaOfTriangle(base,height);

    printf("The area is ???\n", area);

...

Sample Output

Enter the base and height => 7.26 6.83
The area is 24.793



Just calculate using a function and then use that function to printf the answer right? I'm not sure how exactly to do that. After many different things I did, I'm just completely stumped. Heres what I have.

Code:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


//Prototypes
unsigned areaOfTriangle(base,height);


//Declarations


int main ()
{
    printf("Mark Bacani\n");
    printf("Lab Ex #6\n");
    printf("Code::Blocks\n");


//Local Declarations
double base;
double height;
double area;
//Calculations
  printf("Enter the base:\n");
    scanf("%lf",&base);
    printf("Enter the height:");
    scanf("%lf",&height);


area = areaOfTriangle(base,height);






//Result
printf("The area is %lf \n", area);
return 0;
}


//Prototype
unsigned areaOfTriangle (base,height)
{
unsigned areaOfTriangle;


areaOfTriangle =(1/2) * base * height;


return areaOfTriangle;


}
I realize the prototype section is a complete mess. Functions are my kryptonite >

Any help would be greatly appreciated!