Palindrome Program in C Using Recursion

Palindrome program in c using recursion. In this program, we can find the number is palindrome or not in a c programming for beginners to understand the concepts in c.

Recursion Function in C

When a function calls a copy of itself to work on a smaller problem, the process is known as recursion. 

A recursive function is one that calls itself, and such function calls are referred to as recursive calls. 

The process of repeating items in a self-similar manner is known as recursion. 

When a program allows you to call a function inside another function, this is referred to as a recursive call of the function.

If Else Statement in C Program

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 is executed. 

The if-else condition is used to execute both the true and false parts of a condition. 

The if block code is executed if the condition is true, and the else block code is executed if the condition is false.

Palindrome Program in C Using Recursion

#include <stdio.h>
int reverse(int num);
int func(int num);
int main()
{
int num;
printf("Enter The Number");
scanf("%d", &num);
if(func(num) == 1)
{
printf("The Number is Palindrome");
}
else
{
printf("The Number is Not Palindrome");
}
return 0;
}
int func(int num)
{
if(num == reverse(num))
{
return 1;
}
return 0;
}
int reverse(int num)
{
int rem;
static int sum=0;
if(num!=0)
{
rem=num%10;
sum=sum*10+rem;
reverse(num/10);
}
else
return sum;
return sum;
} 

Output:

Enter The Number 999
The Number is Palindrome