This program has runtime error. I can't find it.

c
uva

#1

#include <stdio.h>
#include <string.h>

int main()
{
    char ch[101];
    int len,i,j,start,en,a,group;
    while(scanf("%d",&group)!=0)
    {
        if(group==0)
            break;
        else
        {
            gets(ch);
            len=strlen(ch);
            a=len/group;
            start=0;
            en=0;
            for(i=0;i<len;i++)
            {
                if( (i+1)%a==0)
                {
                    en=i;
                    for(j=en;j>=start;j--)
                    {
                        printf("%c",ch[j]);
                    }
                    start=en+1;
                }
            }
        }
    }
    printf("

");
}


#2

It fails for example for input

4 ab

#3

#include <stdio.h>
#include <string.h>

int main()
{
    char ch[1000];
    int len,i,j,start,a,group;
    while(scanf("%d

“,&group)!=0)
{
if(group==0)
break;
scanf(” “);
gets(ch);
len=strlen(ch);
a=len/group;
if(len<group2)
puts(ch);
else
{
for(i=1;i<=len;i++)
{
start=a
i;
for(j=start-1;j>=start-a;j–)
{
printf(”%c",ch[j]);
}
}
}
}
printf("
");
}

again i find runtime error


#4

i solved the problem. but again i find runtime error


#5

What about

4 abc

?