# Whats wrong with this? (1st question 2nd division isnt working(MAY LUNCHTIME 2020))

#include <stdio.h>

int main(void) {
int testcase;
scanf("%d",&testcase);
int t;
int i,j;
int sum;
int p;
int arr[5];
for(t=0;t!=testcase;t++)
{
sum=0;
for(i=0;i!=5;i++)
scanf("%d",&arr[i]);
scanf("%d",&p);
for(i=0;i!=5;i++)
sum=sum+arr[i];
if(sum*p/5<=24)
printf(“yes”);
else
printf(“no”);
}
return 0;
}

In the future and/or for this post, can you add code formatting and/or/and the problem link?

Your code will fail when sum \in [121, 124] because of integer division screwing you over. Make the condition sum * p <= 120 instead of sum * p / 5 <= 24.

1 Like

thanks a lot man!!!