MAGIC SCHOOL

#include<stdio.h>
void main()
{
int i,n,sum,f,p,t;
scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
for(i=0,sum=0;i<n;i++)
{
scanf("%d",&p);
sum=p+sum;
}
printf("%d",n-(sum/(n-1)));
}

}i am getting SIGSTTP error plz find,

Hi!!

First of all from next time please also include a link to the original question.

Second instead of copy pasting the code here, provide a link to the code so that it is clearly visible(Not mashed up).

A few corrections to be made -

  1. Note that from the given Constrains it is possible that there are 10^5 students who report 10^5 as the count of passed students.
    So Declare sum as long or long long because int would not be able to store such a large number.

  2. n=1 is also possible. in which case your code would try to divide sum by “0” which is an invalid operation. So correct this too.

  3. Also you need to consider cases of invalid inputs. one such example would be when n=5 and one of the student reports 6 as number of passed students.