Q:

Changing int to double changes my result to zero

If I leave all variables  as int I get 32. The division is supposed to give me 32.5 so I thought that changing everything to double would do it, but it just gives me zero...
Here is the code (everything in int):
#include <stdio.h>
#include <stdlib.h>

void sommeTableau(int tableau[], int tailleTableau, int *x, int *average);

int main(int argc, char *argv[])
{
    int tableau[4] = {30, 50, 50};
    int *x = 0;
    int *average = 0;
    const int tailleTab = 4;

    sommeTableau(tableau, tailleTab, &x, &average);

    printf("The average is %d\n", average);

    return 0;
}

void sommeTableau(int tableau[], int tailleTableau, int *x, int *average)
{
  int i = 0;

  for (i = 0 ; i < tailleTableau ; i++)
  {
  *x = *x + tableau[i];
  }
  *average = *x/tailleTableau;

}

So this works and gives me 32... Now if I change everything to double and %d to %f in the printf function, it gives me zero and I don't understand why...

A:

There is lots of mistakes in your code. I corrected all of them   
#include <stdio.h>
#include <stdlib.h>

void sommeTableau(int tableau[], int tailleTableau, int *x, double *average);

int main(int argc, char *argv[])
{
    int tableau[4] = {30, 50, 50};
    int x = 0;
    double average = 0;
    const int tailleTab = 4;

    sommeTableau(tableau, tailleTab, &x, &average);

    printf("The average is %lf\n", average);

    return 0;
}

void sommeTableau(int tableau[], int tailleTableau, int *x, double *average)
{
  int i = 0;

  for (i = 0 ; i < tailleTableau ; i++)
  {
  *x = *x + tableau[i];
  }
  *average = (double)(*x)/(double)tailleTableau;

}

