tiny error with C Program

This is a discussion on tiny error with C Program within the C Programming forums, part of the General Programming Boards category; i got this program to work (yea!!!!!!!!!!!!!!), except there is a tiny error (for the book number and check digit ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    48

    tiny error with C Program

    i got this program to work (yea!!!!!!!!!!!!!!), except there is a tiny error (for the book number and check digit the answers come out negative... how can i fix this?

    here's my code:

    /* ISBN program */

    #include <stdio.h>

    int main()
    {
    int W, XXX, YYYYY, Z;

    printf("Enter ISBN: ");
    /*changed commas for dashes*/
    scanf("%d-%d%d%d-%d%d%d%d%d-%d", &W, &XXX, &YYYYY, &Z);
    /*specified the length of the ints */
    printf("Language: %d\n", W);
    printf("Publisher: %3d\n", XXX);
    printf("Book Number: %5d\n", YYYYY);
    printf("Check Digit: %d\n", Z);

    return 0;
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Stop double posting.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    48
    sorry ab the double post... just wanted to fix the grammatical error~

  4. #4
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Try equate the number of '%d' and their respective variables on the right.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by JohnMayer
    sorry ab the double post... just wanted to fix the grammatical error~
    Then use the edit button
    Last edited by Hammer; 07-11-2002 at 04:15 AM.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  2. Need help with a tiny program
    By Rahiiyja in forum C++ Programming
    Replies: 22
    Last Post: 07-05-2007, 03:15 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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