6.A number is said to be a palindrome if the reverse of a number is same as the original.

Design an algorithm to checkwhether a number is a palindrome or not .Ans. Algorithm: check whether the number is a palindrome or not Input: number, flag Output: number is a palindrome Method:count = 0 while (number > 0) n = number%10 a(count)=n count = count+1 end while half = count/2 palin = true for (j=1 to half in steps of 1 and k=count to half in steps of if (a (j)! =a(k)) palin = false break end if if (palin = true) Display 'Number is a palindrome' else Display 'Number is not a palindrome' end if end for

1 do)

Sign up to vote on this title
UsefulNot useful