Thread: Palindrome checker for numbers

  1. #1
    Registered User
    Join Date
    Jul 2011

    Palindrome checker for numbers

    I have read a lot of topics about this problem.

    #include <stdio.h>
    int main(){
      int number,temp,remainder,sum=0;
      printf("Input a number:\n");
      temp = number;
          remainder=number%10; //Gets Last Digit
          number/=10;          //Truncates Last Digit
          sum=sum*10 + remainder; //Builds value of reversed number
       if (sum==temp)
         printf ("\nThe Number Is A Palindrome ");
         printf ("\nThe Number Is Not A Palindrome ");
       getch ();
       return 0;

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Is there a question in there some place?

    Hope is the first step on the road to disappointment.

  3. #3
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Lehi, UT
    I seem to remember an ACM competition problem within the realm of your... statement. But, again, you have not asked a question.
    -- Will you show me how to c++?

  4. #4
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    London, United Kingdom
    Quote Originally Posted by Ákos Kovács View Post
    I have read a lot of topics about this problem.
    Well done.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. spelling checker
    By Tom.b in forum C Programming
    Replies: 8
    Last Post: 11-12-2009, 11:17 PM
  2. Spell Checker
    By DeepFyre in forum Tech Board
    Replies: 2
    Last Post: 02-11-2005, 12:17 PM
  3. URL checker
    By bigSteve in forum C++ Programming
    Replies: 10
    Last Post: 05-24-2004, 04:48 PM
  4. spell checker in c needs help
    By madmax in forum C Programming
    Replies: 3
    Last Post: 03-13-2003, 09:36 AM
  5. spell checker
    By bob20 in forum Windows Programming
    Replies: 3
    Last Post: 12-03-2002, 02:35 AM