Whenever I try and run this my compiler shows a random error and a bunch of binary numbers. I have no idea what is wrong. Am I missing something? Its a program to check if a number is a palindrome.
#include <stdio.h>
#include <math.h>
int palindromecheck (int number)
{
int numbercount = 0;
int n[100];
int j;
int sum = 0;
int savenumber;
savenumber = number;
for (j = 0; number != 0; ++j)
{
if (number < 10)
n[j] = number;
else
{
n[j] = number % 10;
number = number/10;
}
++numbercount;
}
for (j = 0; numbercount != 0; ++j)
{
sum += n[j]*(pow(10, (numbercount-1)));
--numbercount;
}
if (sum == savenumber)
return (1);
else
return (0);
}
main ()
{
float a;
printf("Enter number: ");
scanf("%i", &a);
if (palindromecheck(a))
printf("palindrome");
else
printf("not palindrome");
}