'Why is this C code not returning a decimal even I use casting [closed]

#include <stdio.h>

int main()
{
    int i;
    int sum = 0;
    int num_of_stu = 0;
    int grade[100];
    double average;
    for (i = 0; i < 100; i++)
    {
        printf("grade : ");
        scanf("%d", &grade[i]);
        num_of_stu = i;
        if (grade[i] < 0)
        {
            break;
        }
    }
    for (i = 0; i < num_of_stu; i++)
    {
        sum += grade[i];
    }
    average = (double)sum / num_of_stu;
    printf("%f", average);
    return 0;
}

I enter 90 and 91 into grade[0] and grade[1] then average returns 90.000000. Why average returns 90.000000 not 90.500000?

c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source