Practical 13 Write a program to check whether the given number is palindrome or not.



domains
            N,Sum,Sum1,S,A,C,D,E=integer
predicates
            go
            palin(integer,integer,integer)
clauses
      go:-
      write("Enter the number: "),nl,
      readint(N),
      S=N,
      Sum=0,
     palin(N,S,Sum).
     palin(N,S,Sum):-
     N>0,
     C=N mod 10,
     Sum1=(Sum*10)+C,
     A=Sum1,
     D=N/10,
     E=D-0.5,
     palin(E,S,A),
     palin(_,S,Sum):-
     S=Sum,
     write("Given number is Palindrome"),nl.
     palin(_,_,_):-
      write("Given number is not palindrome").


No comments:

Post a Comment