Browse Source

add dreieckFlaeche

main
Fdai7396 2 years ago
parent
commit
a37210c52a
  1. 4
      src/funktion.c
  2. 1
      src/funktion.h
  3. 7
      src/main.c

4
src/funktion.c

@ -324,3 +324,7 @@ double kreisFlaeche(double r) {
double kreisUmfang(double r) { double kreisUmfang(double r) {
return 2 * M_PI * r; return 2 * M_PI * r;
} }
double dreieckFlaeche(double a, double b, double c) {
double s = (a + b + c) / 2;
return sqrt(s * (s - a) * (s - b) * (s - c));
}

1
src/funktion.h

@ -55,5 +55,6 @@ double prozentsatz(double ein, double prozent);
double grundwert(double ein, double prozent); double grundwert(double ein, double prozent);
double kreisFlaeche(double r); double kreisFlaeche(double r);
double kreisUmfang(double r); double kreisUmfang(double r);
double dreieckFlaeche(double a, double b, double c);
#endif #endif

7
src/main.c

@ -248,4 +248,11 @@ int main()
r = getValue('r'); r = getValue('r');
kreisUmfang(r); kreisUmfang(r);
a = getValue('a');
b = getValue('b');
c = getValue('c');
dreieckFlaeche(a,b,c);
double s = (a + b + c) / 2;
printf("Die Flaeche des Dreiecks betraegt: %f\n", sqrt(s * (s - a) * (s - b) * (s - c)));
} }
Loading…
Cancel
Save