This is the code. S (arithmetic mean) is done right, I have valid result. But for other calculations I'm getting this error: Floating point exception (core dumped)
.
Does anyone know what is wrong with my code?
#include <stdio.h>
#include <math.h>
main () {
int a,b,c;
double s,h,g,k;
printf ("unesite 3 cela broja\n");
scanf ("%d%d%d", &a, &b, &c);
s=(a+b+c)/3;
printf ("aritmeticka s.v. je: %.2lf\n", s);
/* this should be formula for medium value of harmonic number */
h=3/((1/a)+(1/b)+(1/c));
printf ("harmonijska s.v. je: %.2lf\n", h);
/* this should be http://upload.wikimedia.org/math/a/f/f/aff7a590d055d563ceea52fd66fe7ee2.png */
k=sqrt ((pow(a,2)+pow(b,2)+pow(c,2))/3);
printf ("kvadratna s.v. je: %.2lf\n", k);
/* and this http://upload.wikimedia.org/math/e/3/4/e348daea2f4f2bb60f5cb40706fcbad4.png */
g=pow(a*b*c,1/3);
printf ("geometrijska s.v. je: %.2lf\n", g);
return 0;
}