Palindrome Program in C Using For Loop

Palindrome program in c using for loop. In this program, we can execute this program using for loop in c programming language.

Palindrome Definition in C

Madam, I’m Adam is an example of a palindrome, which is a word, phrase, or sentence that reads the same backwards and forwards. 

When spelled backwards, semordnilaps (the word palindromes in reverse) are words that spell other words. 

A palindrome, such as madam or racecar, is a word, number, phrase, or other sequence of characters that reads the same backward as forward.

If Else Statement in C

In C, the if-else statement is used to carry out operations based on a set of conditions. 

If and only if the given condition is true, the operations specified in the if block are executed. 

If a specified condition is true, use if to specify a block of code to be executed. 

If the same condition is false, use else to specify a block of code to run. If the first condition is false, use else if to specify a new condition to test.

Palindrome Program in C Using For Loop

#include<stdio.h>
int main()
{
int i,n,r,s=0;
printf("\n Enter The Number");
scanf("%d",&n);
for(i=n;i>0;)
{
r=i%10;
s=s*10+r;
i=i/10;
}
if(s==n)
{
printf("\n %d is a Palindrome Number",n);
}
else
{
printf("\n %d is not a Palindrome Number",n);
}
}

Output:

Enter The Number9999

9999 is a Palindrome Number