Computer Science, asked by lalithak835, 11 months ago

write an algorithm to find out whether the entered two digit number is palindrome or not​

Answers

Answered by Anonymous
31

Answer

A recursive function to find out whether num is palindrome  

// or not. Initially, dupNum contains address of a copy of num.  

bool isPalUtil(int num, int* dupNum)  

{  

   // Base case (needed for recursion termination): This statement  

   // mainly compares the first digit with the last digit  

   if (oneDigit(num))  

       return (num == (*dupNum) % 10);  

 

   // This is the key line in this method. Note that all recursive  

   // calls have a separate copy of num, but they all share same copy  

   // of *dupNum. We divide num while moving up the recursion tree  

   if (!isPalUtil(num/10, dupNum))  

       return false;  

 

   // The following statements are executed when we move up the  

   // recursion call tree  

   *dupNum /= 10;  

 

   // At this point, if num%10 contains i'th digit from beiginning,  

   // then (*dupNum)%10 contains i'th digit from end  

   return (num % 10 == (*dupNum) % 10);  

}

Answered by azrajabeen1985
0

Answer:

What is palindrome

Mark me as brainlist

Similar questions