Problem:Decreasing String

Why this program is not correct?

#include<stdio.h>
int main()
{
int t,k,c;
char i;
scanf("%d",&t);
while(t--)
{
    scanf("%d",&k);
    if(k==0)
        printf("\n");
    else
    {
    c=k/26;
    k+=c;
    k%=26;
    for(i=(97+k);i>=97;i--)
        printf("%c",i);
    while(c>0)
    {
        for(i=122;i>=97;i--)
            printf("%c",i);
        c--;
    }
    printf("\n");
    }
}
return 0;
}

Haha so I posted an answer to this really quickly and it turned out I was completely wrong so I deleted it, but now I am fairly confident I actually found a legitimate problem with your code. :slight_smile:

Try the following case:

1
51

Your Response: azyxwvutsrqponmlkjihgfedcba

Correct Response: bazyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba

Hope it helps!

Hint : the sequence zyx…cba has only 25 positions where the character at that position comes alphabetically later than the character immediately after it. Not 26!!