How Can i result this C++ code. float type or double problem? :     #include <stdio.h>
        int main()
      {
          int i;
        const int N = 4;
        double a=0, b=0, c=0, d=0;
      for (i = 1 ; i <= N ; i++)
      {
        a += i;
        b += i * i;
      }
        c = a / N;
        d = b / N - c * c;
        printf("%.0f\n", d);
        return 0;
    }





It`s result is 1


But I don`t know exactly why result is 1.

I think c is 3;

and N-c*c is -2.25

so d is -13 .

so I think print d`s result is -13 but result is 1 

why this result comes from?

please help me~!!