C language help"determine palindrome"

This is a discussion on C language help"determine palindrome" within the C Programming forums, part of the General Programming Boards category; please help me out with this coding I need to determine if the set of the number is Palsindrome. Code: ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    11

    C language help"determine palindrome"

    please help me out with this coding I need to determine if the set of the number is Palsindrome.
    Code:
       1     #include <stdio.h>
          2
          3       int main()
          4       {
          5
          6         int number;
          7         int a=/*needed number*/;
          8         int x=0;
          9         int y=a;
         10
         11            printf("Enter the set of number:");
         12            scanf("%d", &number);
         13                 while(z)
         14          {
         15             x*=10;
         16             x+=z%10;
         17             z/=10;
         18          }
         19
         20            if(x==a){
         21
         22               printf("The set of number is a Palindrome");
         23
         24         }
         25
         26         else{
         27                 printf("The set of number is not a Palindrome");
         28
         29         }
         30           return 0;
         31      }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    This looks like "homework", which this forum tends to not just "give the answer", but rather tyr to help the poster find the right answer him/herself.

    So, my hint is: what is "a" and "y "used for?

    --
    Mats

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    33
    Quote Originally Posted by shaitan_superma View Post
    please help me out with this coding I need to determine if the set of the number is Palsindrome.
    Code:
       1     #include <stdio.h>
          2
          3       int main()
          4       {
          5
          6         int number;
          7         int a=/*needed number*/;
          8         int x=0;
          9         int y=a;
         10
         11            printf("Enter the set of number:");
         12            scanf("%d", &number);
         13                 while(z)
         14          {
         15             x*=10;
         16             x+=z%10;
         17             z/=10;
         18          }
         19
         20            if(x==a){
         21
         22               printf("The set of number is a Palindrome");
         23
         24         }
         25
         26         else{
         27                 printf("The set of number is not a Palindrome");
         28
         29         }
         30           return 0;
         31      }
    Where did u declared 'z'?

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    thats the first time I have seen a poster use the line numbers in the post
    I'm just trying to be a better person - My Name Is Earl

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Read the FAQ, it tells you how to get a number from the user (safely) - find the link yourself. Ensure you've researched how to find if a number is a Palsindrome, then get into coding - don't just dive in.

    You should,
    * Draw up an IPO chart (Input, Processing, Output) - since you seem a bit confused as to what you need.
    * Draw up a flowchart or an NS diagram (research them) - so you can nut out the algorithm

    Hand the design in with the solution, even if it's not asked of - usually you can score a couple of marks if the teacher see's you've done it correct in design, but made a mistake in the programming or something.

    Have fun.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  2. What language did they make Java in?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 07-03-2005, 05:18 PM
  3. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 02:40 PM
  4. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 02:11 PM
  5. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 02:20 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21