Thursday, 14 September 2017

11th D Prg-9 Write an algorithm and program to check whether a given number is palindrome or not.

Algorithm
Input
1. n
Output
1. Palindrome or not
Method:
1. Start
2. Read n
3. Write n
4. n1=n;
5. rev=0;
6.  // logic
  do
  {
      r= n % 10;
      rev = rev * 10 + r;
     n = n / 10;
  } while (n != 0);
7. if (n1 == rev)
    write " the given number is palidrome ";
    else
    write " The given number is not palindrome";
8.stop
Example:
1. 121 is a plindrome
2. 256 is not a palindrome
 


No comments:

Post a Comment