C Program to Check Palindrome
18CPL17/27
Program 3:-
Develop a program to find the reverse of a positive integer and check for palindrome or not. Display appropriate messages.
ALGORITHM
Purpose: To check the given integer is palindrome or not
Input: Num
Output: Reverse and palindrome or not
START
STEP 1: [Input a number]
read num
STEP 2: [To check the given number is 4 digits or not] If the number less than 999 or greater than 9999 print “it is not a four-digit number”
Go to step 5
STEP 3: [Calculate the reverse of the given number]
Temp=num
Loop while temp not equal to 0
Remainder=temp%10
Temp=temp/10
Reverse=reverse*10+remainder
print “reverse number”
STEP 4: [Check number is a palindrome or not]
If Num is equal to reverse
print “Num is a palindrome “
Else
print “Num is not a palindrome”
STEP 5: [Finished]
STOP
FLOWCHART
C Code
Output
******************************************************************************
Output 2:
Enter a number to check if it is a palindrome or not
1234
1234 is not a palindrome number
Output 3:
Enter a number to check if it is a palindrome or not
1221
1221 is a palindrome number
******************************************************************************
No comments:
For Query and doubts!