Please help

I have a little problem trying to create this little program that calculates: arithmetic average (aka "media") // geometric average (aka "media2") // harmonic average (aka "media3"). This is the code:

#include <iostream.h>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <sstream>
#include <math.h>
#include <stdio.h>

void main(void)
{
float a, b, c;
printf("Introduceti valoarea lui a: ");
scanf("%d",&a);
printf("Introduceti valoarea lui b: ");
scanf("%d",&b);
printf("Introduceti valoarea lui c: ");
scanf("%d",&c);
float media;
media = (a+b+c)/3;
printf("Media aritmetica este: %d\n",media);
float media2;
media2 = pow(a*b*c,1.0/3.0);
printf("Media geometrica este: %d\n",media2);
float media3;
media3 = 3/(1/a+1/b+1/c);
printf("Media armonica este: %d\n",media3);
}

May someone tell me what have I done wrong? Because it doesn't calculate even the simplest task like arithmetic average... Thank you!
Last edited on
Hey mate couple of things I noticed, firstly not sure if this is an issue with your compiler but when I load up your program it requires int main(void) { rather than void main(void){ (main returns an int value containing the errors so most compilers require it to have an int return format.)

Also, you are using float values but have %d in your program, %d works for integers but it get's a little messy when using it with floats, try using %f instead :)
Last edited on
Topic archived. No new replies allowed.