Palindrome number in C language: A palindrome number is the same as the reverse number. Some palindrome numbers, for example, are 8, 121, 212, 12321, and -454. We first reverse the palindrome to check whether a number is a palindrome and then compare the number we obtained with the original. The number is a palindrome if both are the same; otherwise, it is not a palindrome string program.
In this program, some required string functions also used like “strcpy” for copying the strings. The other one is “strrev” that will use to reverse the string for palindrome condition. And “strcmp” also been used for comparing the string with each other after reversing if that strings got matched then it will be palindrome else not.
Problem Statement:
The two strings will be use to check for palindrome situation with the use of String reverse function and control statement for checking both the strings. Write a program to read the data and determine the following:
- The Entered String Must Be checked out.
- If-else condition also is come into use checking both string.
Here is source code of the C Program Write a Program to Check the String is Palindrome or Not . The C program is successfully compiled. The program output is also shown below.
void main() { char a[10],b[10]; clrscr(); printf("Enter any String : "); scanf("%s",a); printf("a=%s",a); strcpy(b,a); strrev(b); printf("\nb=%s",b); if(strcmp(a,b)==0) { printf("\nString is Palindrome"); } else { printf("\nNot Palindrome"); } getch(); }