I have written a program that checks if a 6-letter word is a palindrome or not. The code for it is given below:
#include <stdio.h>
int main()
{
char l1, l2, l3, l4, l5, l6;
printf("Enter a 6-letter word\n");
scanf("%c", &l1);
scanf("%c", &l2);
scanf("%c", &l3);
scanf("%c", &l4);
scanf("%c", &l5);
scanf("%c", &l6);
printf("Let's see if this word is a palindrome. The reversed word is: %c%c%c%c%c%c", l6, l5, l4, l3, l2, l1);
return 0;
}
However, when I run the code, although I included 6 scanf functions to obtain the 6 letters as input, the program only takes three letters and reverses them, and the rest I am not able to give as input.
Can somebody help me with this one?