24)C PROGRAM TO CHECK WHETHER THE NUMBER OR STRING IS PALINDROME OR NOT
(A)NUMBER IS PALINDROME OR NOT
LOGIC:- When a number is equal to its reverse number, then the number is palindrome.Let number is 121 the reverse of this number is also 121 so 121 is a palindrome number.So for palindrome number reverse logic is required, which we did in previous program where string is reversed.
EXAMPLE:-
(B) STRING IS PALINDROME OR NOT
LOGIC:- In string case we compare a string first character with its last character if they are same then 2nd character compare with the 2nd last character..and so on.If any character is not equal then string is not palindrome otherwise it is palindrome.
EXAMPLE:-
TASK:"""TAKEN STRING FROM USER AND THEN CHECK"""
===""IF YOU LIKE THIS CONCEPT,SHARE IT WITH YOUR FRIENDS===
(A)NUMBER IS PALINDROME OR NOT
LOGIC:- When a number is equal to its reverse number, then the number is palindrome.Let number is 121 the reverse of this number is also 121 so 121 is a palindrome number.So for palindrome number reverse logic is required, which we did in previous program where string is reversed.
EXAMPLE:-
(B) STRING IS PALINDROME OR NOT
LOGIC:- In string case we compare a string first character with its last character if they are same then 2nd character compare with the 2nd last character..and so on.If any character is not equal then string is not palindrome otherwise it is palindrome.
EXAMPLE:-
TASK:"""TAKEN STRING FROM USER AND THEN CHECK"""
===""IF YOU LIKE THIS CONCEPT,SHARE IT WITH YOUR FRIENDS===
Comments
Post a Comment