This is a program of while loop in which we are going to verify whether the number is a Palindrome or not with the help of the C Programming language.
#include <stdio.h>
int main()
{
int num; // number to be taken
int n2 = 0; // reverse number being generated
int rem; // remainder
int qu; // quotient
printf("Enter number to check if its Palindrome or not :\n");
scanf("%d", &num);
int n = num;
// value of num, initiaized in n to perform operations on n
// & num will be prepared to compare later
while (n > 0)
{
rem = n % 10; // found remainder
n2 = n2 * 10 + rem; // generating number in reverse
qu = n / 10;
n = qu;
}
if (n2 == num)
{
printf("%d is a Palindrome number !", num);
}
else
{
printf("%d is NOT a Palindrome number !", num);
}
return 0;
}
//......Coded by ARADHANA MISHRA
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP