This is a program to find whether a given number is a palindrome or not. In this case the condition in the if statement even though it is true isnt getting executed and the program is terminationg.
#include <stdio.h>
#include <math.h>
int count(int n)
{
int counts;
counts = 0;
do{
n = n/10;
counts++;
}while(n!=0);
return counts;
}
int main()
{
int i=0;
int numb;
printf("Enter a number: \n");
scanf("%d",&numb);
int num1=numb;
int num2=numb;
int c;
int power;
int n1,n2;
int c_num = count(numb);
do{
c = count(num1);
if((num1/pow(10,c-1))==(num2%10)){
power = pow(10,c-1);
n1 = num1 % power;
n2 = num2/10;
num1 = n1;
num2 = n2;
i++;}
else{
num1=0;
num2=0;
}
}while(num1!=0);
if (c_num==i){
printf("It is a Palindrome number.");
}
else{
printf("It is not a Palindrome number.");
}
return 0;
}