algorithm to print the digits in the correct order

Posted by Aga Waw on Programmers See other posts from Programmers or by Aga Waw
Published on 2012-10-23T19:50:03Z Indexed on 2012/10/23 23:17 UTC
Read the original article Hit count: 276

Filed under:
|

I've been trying to write an algorithm that will print separately the digits from an integer. I have to write it in Pseudocode. I know how to write an algorithm that reverse the digits.

digi(n): 
  while n != 0:
    x = n % 10 
    n = n // 10 
    print (x)

But I don't know how to write an algorithm to print the digits in the correct order. f.eg. the input is integer 123467 and the output is: 1 2 3 4 6 7 The numbers will be input from the user, and we cannot convert them to a string. I just need help gettin started on writing algorithms. Thanks

© Programmers or respective owner

Related posts about algorithms

Related posts about pseudocode