Basic 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
//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
Binary Tree Traversal in Data Structure Program
Program to Find Substring in a String in C Without Using Library Function
C Program to Find Length of String Without Using strlen Function
C Program to Implement Character Count in Data Link Layer
Alphabet Pattern Program in C Using For Loop
Multiplication of Two Large Numbers in C
C Program to Compute Quotient and Remainder
Fibonacci Series Program in C Using Recursion
Binary Search in C Program Using Recursion
Binary Search in C Program Using While Loop
Binary releases – Code::Blocks
GDB online Debugger | Compiler – Code, Compile, Run, Debug online C, C++
Online Compiler and Editor/IDE for Java, C/C++, PHP, Python, Perl, etc
Applications of C Programming That Will Make You Fall In Love With C