Electro4u 28 Dec 2022 5 views 0 comments C Programming

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

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,  POP,  LOL, 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!

0 Comments

No comments yet, Be the first to comment.

Post a Comment

Please sign in to post a comment.

Related Posts

C Bitwise Operators Explained: 10 Practice Programs with Output

E.1: Bitwise vs. Logical Operators#include<stdio.h> int main(void){ int x=7,y=19; printf("%d %d ",x&y...

AG Anvesh G 29 Nov 2026
Bit wise operators Assignment

Bitwise Operators practical assignment: Take runtime input, bit-level manipulation, and different data units r...

AG Anvesh G 27 Sep 2026
Understanding Float and Double Binary Representation in C

Understanding Float and Double Binary Representation in CIntroduction:When we store decimal numbers such as 10...

AG Anvesh G 31 May 2026