Sunday, June 14, 2020

palindrome missing alphabet in c

String S which is a palindrome is passed as the input. But just one alphabet A is missing in S. The program must print the missing alphabet A.
Note: The FIRST alphabet of S will always be present.

Input Format:
The first line contains S.

Output Format:
The first line contains the missing alphabet A.

Example Input/Output 1:
Input:
malayaam

Output:
l

Solution:
int main()
{
char s[100];
scanf("%s",s);
int l=strlen(s)-1;
for(int i=0;i<strlen(s);i++){
    if(s[i]!=s[l]){
        printf("%c",s[i]);
        break;
    }
    else{
        l--;
    }
}
}

1 comment:

MFIB Comma Separated Integers

Fill in the blanks with code so that the program must accept three integers separated by a space and print them separated by a comma as the ...