yes as u said i changed the \n condition by finding its length and its giving correct answer at all possible test cases....still wa 
plzz tel me if u know some boundary test cases that generally ppl don think of...
#include<stdio.h>
#include<iostream>
#include<string.h>
#define BUFSIZ 20004
using namespace std;
main()
{
int test,garbage;
scanf("%d",&test);
char array[BUFSIZ],hash[BUFSIZ];
garbage=getchar();
while(test--)
{
bzero(hash,sizeof(char)*BUFSIZ);
fgets(array,BUFSIZ,stdin);
int len2=strlen(array);
array[len2-1]='\0';
int i=0,len=0,len1=0,max1=0,max=0,flag=0,flag1=0;
while(i<(len2-1))
{
while(isspace(array[i]))
{
if(i==(len2-2))
{flag=1;break;}
i++;
}
if(flag)
break;
while(array[i]<='z' && array[i]>='a')
{
len++;
i++;
}
if(!len1)
len1=len;
//printf("hash[%d] is %d\n",len,hash[len]);
if(len==len1)
hash[len]++;
else
{
if(max1>hash[len1])
hash[len1]=max1;
len1=len;
max1=hash[len];
hash[len]=1;
}
printf("hash[%d] is %d\n",len,hash[len]);
if(max<hash[len])
{max=hash[len];}
len=0;
}
if(!flag)
{
if(max1>hash[len1])
{
hash[len1]=max1;
}
if(max<hash[len1])
max=hash[len1];
}
printf("%d\n",max);
}
}