Question:C program to check if a number is palindrome using recursion 

Answer 
#include<stdio.h>

int checkPalindrome(int);
int main(){
    int num,sum;

    printf("Enter a number: ");
    scanf("%d",&num);

    sum = checkPalindrome(num);

    if(num==sum)
         printf("%d is a palindrome",num);
    else
    printf("%d is not a palindrome",num);

    return 0;
}

int checkPalindrome(int num){

    static int sum=0,r;

    if(num!=0){
         r=num%10;
         sum=sum*10+r;
         checkPalindrome(num/10);
    }

    return sum;
}
Sample output: Enter a number: 25 25 is not a palindrome 

+ Report
Total Preview: 579
C program to check if a number is palindrome using recursion
Copyright © 2024. Powered by Intellect Software Ltd