A palindrome is a string that reads the same regardless of whether it is in a forward or backwards order. For example, the word radar
is a palindrome because it reads the same way forwards and backwards.
Determining whether the string is a palindrome
How to do it…
- Define two 80-character strings called str and rev(assuming your string will not exceed 79 characters). Your string can be of any length, but remember that the last position in the string is fixed for the null character \0:
char str[80],rev[80];
- Enter characters that will be assigned to the str string:
printf("Enter a string: ");
scanf("%s",str);
- Compute the length of the string using the strlen...