Thread: rotating the digits in a number

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    26

    rotating the digits in a number

    Hi guys !
    I have to make a program that rotates the digits in a number with k positions to the right. I am not sure if I understand this correctly.
    I've found this problem in a book without any details given.
    What should I do ? I guess the number is in base 10,not in base 2...What do you think?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    It's the same problem in any base.

    "1234" in base 10, rotated by 2 is "3412"
    "1101" in base 2, rotated by 2 is "0111"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Different digits in number
    By cowa in forum C Programming
    Replies: 2
    Last Post: 12-27-2009, 08:29 PM
  2. how to sum the digits of a number?
    By transgalactic2 in forum C Programming
    Replies: 34
    Last Post: 12-23-2008, 06:00 PM
  3. How do I add the digits of a number ?
    By abh!shek in forum C Programming
    Replies: 16
    Last Post: 02-06-2008, 05:57 AM
  4. Number of digits in a decimal number
    By maverix in forum C Programming
    Replies: 7
    Last Post: 11-04-2007, 12:12 PM
  5. Number of digits?
    By falador in forum C Programming
    Replies: 2
    Last Post: 05-13-2004, 03:52 AM