separating numbers

This is a discussion on separating numbers within the C Programming forums, part of the General Programming Boards category; Im working on a program that will take a routing number from a check (8digits)and determine the checks number (9th ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    22

    separating numbers

    Im working on a program that will take a routing number from a check (8digits)and determine the checks number (9th digit). I got that far and was able to separate the digits
    doing this: printf("Enter first eight digits of RTN: "); scanf("%1d%1d%1d%1d%1d%1d%1d%1d",&n1,&n2,&n3,&n4,& n5,&n6,&n7,&n8);
    but now i have to determine, for instance, the location or reserve bank. How can i get the 1st 2 digits, say 123456789, so 1 and 2, to be 12, not 1+2 =3?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Make the number. You want base 10, so for a two digit number:

    num1 = number 1 * 10,
    num2 = number 2 * 1 (you can skip this, but I wanted to be complete)

    and then add num1 + num2.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Separating Axis Theorem
    By Astra in forum Game Programming
    Replies: 10
    Last Post: 07-29-2011, 04:27 PM
  2. Separating class implementation
    By Litz in forum C++ Programming
    Replies: 5
    Last Post: 03-07-2009, 05:41 AM
  3. need help separating a real number
    By jorgejags in forum C Programming
    Replies: 4
    Last Post: 09-16-2008, 11:45 AM
  4. Separating Axis Theorem
    By Kenki in forum Game Programming
    Replies: 20
    Last Post: 05-22-2005, 12:49 PM
  5. Separating an Integer into digits
    By Mr Curtains in forum C Programming
    Replies: 2
    Last Post: 03-22-2003, 03:58 AM

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