3/07/2016

C Program to Check a Number is Palindrome or Not Using While Loop

Problem :- Write a C Program to Check Whether a Number is Palindrome or Not Using While Loop

Logic :- What Is Palindrome ?

"a word, phrase, or sequence that reads the same backwards as forwards"
" Matlab Ulta Seedha Ek Saman "

Simple if string is "12321" compare First '1' to Last '1' same continue repeat if all Number's are shame then Number Is Palindrome .If you understood what is palindrome then try to solve the given problem Check string is palindrome .

Try Yourself C++ Program To Check String Is Palindrome Or Not

Solution :-

#include<stdio.h>
int main()
{
//Ghanendra Yadav
int n, reverse=0, rem,temp;

printf("Enter an Integer To Check Number:\n");
scanf("%d", &n);
  
temp=n;
   
while(temp!=0)
{
rem=temp%10;
reverse=reverse*10+rem;
temp/=10;
}

   if(reverse==n)
       printf("%d is a Palindrome Number.",n);
   else
       printf("%d is Not a Palindrome Number.",n);
   return 0;
}

Output:-

C Program to Check a Number is Palindrome or Not Using While Loop

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: