0

I am solving the hacker rank problem plus minus and encountered the problem where the division gives 0.0000

int main()
{
    int array_size;
    printf("Enter the size of array: \n");
    scanf("%d",&array_size);

    int array [array_size];
    for(int i=0;i<array_size;i++)
    {
        scanf("%d",&array[i]);
    }

    int positive=0;
    int negative=0;
    int zero=0;
    for(int i =0; i<array_size;i++)
    {
        if(array[i]<0)
        {
            negative++;
        }
        if(array[i]>0)
        {
            positive++;
        }
        if(array[i]=0)
        {
            zero++;
        }
    }
    float x = positive / array_size;
    float y = negative / array_size;
    float z = zero / array_size;
    printf("%lf \n",x);
    printf("%lf \n",y);
    printf("%lf \n",z);

    return 1;

}

Actual Result:- 0.00000000 0.00000000 0.00000000

Expected Result:- The actual divisions...

Janit Lodha
  • 21
  • 1
  • 2

0 Answers0