#include #include float triangolo(float x, float x1, float x2, float xc, float h) { float m1, m2; if ( ( xc < x1 ) || ( xc > x2 ) ) { printf("xc (=%f) deve esse compreso fra x1 e x2\n", xc); return 0.; } printf("Bene, ora cominciamo a fare i conti\n"); m1 = h / (xc-x1); m2 = h / (xc-x2); printf("Pendenze: m1 = %f; m2 = %f\n", m1, m2); return 0.; } int main() { float x1=0, x2=10, xc=5, h = 5; float y, area; area = (x2-x1) * h / 2.; printf("Area (formula) : %f\n", area); y = triangolo(5.0, x1, x2, xc, h); printf("y = %.f\n", y); }