a program in c to check if a given number is a palindrome or not using a do while loop.

A Palindrome Logic in C program:
1. Ask the user to enter some input.
2. Store the entered input data in a temporary variable.
3. Find the reverse of the user input.
4. Compare the reverse value of the input data with a temporary variable.
5. If the reverse and temporary variables are the same, print that is a palindrome.
6. print not palindrome If the reverse and temporary variables do not match.


Working of do While Loop
A while loop is executed repeatedly based on the condition specified after the word while in the code.
the body of the loop executes and check the condition ,If this condition is true, the code within the parentheses will execute the do while loop. If the condition is false, the for loop jumps to the code after the loop without executing the code. Let's see how to check if a number is palindrome using a loop.


#include<stdio.h>
int main()
{
int n, rev_number = 0, temp;
printf("Enter a number to check palindrome value:\n");
// allow user to enter a number
scanf("%d", &n); // takes value from user
temp = n; //store number n in to temp variable

do{
rev_number=rev_number*10;
rev_number=rev_number+n%10;
n=n/10;
}while (n!= 0);
//check reverse number with original number
if(temp==rev_number)
{
//if match original given number then show palindrome
printf("\nThe Given number %d is palindrome",temp);
}
else
{
// If it does not match with original number show not palindrome
printf("\nGiven number %d is not palindrome",temp);
}
return 0;
}

Output
Enter a number to check palindrome value
121
The Given number 121 is palindrome

Previous :-->> 5.Write a program in c to display the Fibonacci series up to a given number using a while loop.
 -->> NEXT: 7.Write a program to in c programming to calculate the power of a number using a for loop and while loop.
-->>ALL Loops Assignments in c