Here are few modification that I made to your code and it got Ac.
--> First of all , you don't have to use strtok cos you know it terminates with a zero.
--> 1 is not a perfect number
--> You don't have to store the numbers in an array before processing..
.. the best is to read a number and process it immediately.
Here is a slight modification of your code which got AC. Note the changes
int check(int bah);
int main( )
while( scanf("%d", &a ) )
if( a == 0 )
switch( check(a) )
case 0: printf("%5d %s\n", a, "DEFICIENT");break;
case 1: printf("%5d %s\n", a, "PERFECT");break;
case 2: printf("%5d %s\n", a, "ABUNDANT");break;
printf("END OF OUTPUT\n");
int check(int bah)
int soma=0, j;
for(j=1; j<bah; j++)
else return 0;
Hope it helps and that you can see the difference.