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");

}

WOOOOOOOOOOOOOOOOOOOOO JUST FOUND THE PROBLEM.
needed a number = 0 after n[j] = number;

Thanks anyways :DDDDDDDDDDDDDDDDDDDDDDDD

A couple problems:
1) line 11: you have to set number to 0 so that the loop will stop

2) line 27: change data type to int because that's what palindromecheck() expects as its parameter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.