program to check whether the given string is a palindrome or not in c

28 Dec 2022 Balmiki Kumar 0 C Programming

What is a palindrome string?

The reverse of a given string is equal to the same string is called a palindrome string. A palindrome string is a string that reads the same forwards and backward. In other words, if you reverse the order of the characters in a palindrome string, you will get the same string. Palindromes can be made up of letters, numbers, or a combination of both. For example, "racecar" is a palindrome string because it reads the same backward as forwards, while "hello" is not a palindrome string because it reads differently when the characters are reversed. Palindromes are commonly used in computer programming as a way to test algorithms or as a fun exercise to practice string manipulation.

Examples:- RADAR MADAM POPLOL, RUBBER

Program: C Program to Print the Palindrome of Any Number

#include<stdio.h>
#include<string.h>
int main() {
 char string1[20];
 int i, length;
 int flag = 0;
 printf("Enter a string: \n");
 scanf("%s", string1);
 length = strlen(string1);
 for(i=0;i < length ;i++){
 if(string1[i] != string1[length-i-1]){
 flag = 1;
 break;
 }
 }
 if (flag) {
 printf("%s is not a palindrome\n", string1);
 }
 else {
 printf("%s is a palindrome\n", string1);
 }
 return 0;
}

Output:

Enter a string: radar
"radar" is a palindrome

Top Resources

write a program to print palindrome numbers in 10 array elements.

Writing a C Program to Print Available Palindrome Numbers between 50 to 100 using a While Loop

write a program to print perfect numbers in 10 array elements.

Write a program to find out how many angstrom number in 10 elements of an array and count it.

Write a program to find out how many prime number are present in a given 10 elements of an array

Print Prime Numbers Between 50 and 100 Using C programming language

Further Reading:

 For further information and examples, Please visit[ C-Programming From Scratch to Advanced 2023-2024]

 

Note: If you encounter any issues or specific errors when running this program, please let me know and I'll be happy to help debug them!

BY: Balmiki Kumar

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.