Help me in solving STRCC11 problem

My issue

My code

#include <stdio.h>
#include <string.h>
char opp_letter(char c)
{
    if(c>='a' && c<='z')
    {
        return 'a'+'z'-c;
    }
    return c;
}
int main() 
{
    int t;
    scanf("%d", &t);
    
    while (t--)
    {
        char A[100], B[100];
        int i;
        scanf("%s", A);
        for(i=0;i<strlen(A);i++)
        {
            B[i]=opp_letter(A[i]);
        }
        printf("\n");
        printf("%s",B);
    }
    return 0;
}

Learning course: Solve Programming problems using C
Problem Link: CodeChef: Practical coding for everyone

there is no such function like opp_letter u have to build some logic to do that

@dpcoder_007 I have written the logic for opp_letter function before the main function

@nitheesha39
sorry i didn’t see that
the thing is u have to clear the char array each time u proceed for new input
using memset u can do this

i have corrected it in your code hope u will get it

include <stdio.h>
include <string.h>
char opp_letter(char c)
{
if(c>=‘a’ && c<=‘z’)
{
return ‘a’+‘z’-c;
}
return c;
}
int main()
{
int t;
scanf(“%d”, &t);

while (t--)
{
    char A[100], B[100];
    memset(A,'\0',sizeof(A));
    memset(B,'\0',sizeof(B));
    int i;
    scanf("%s", A);
    for(i=0;i<strlen(A);i++)
    {
        B[i]=opp_letter(A[i]);
    }
    
    printf("\n");
    printf("%s",B);
    
}
return 0;

}

1 Like

@dpcoder_007 Thank you. It helped me.