rotating the digits in a number

This is a discussion on rotating the digits in a number within the C++ Programming forums, part of the General Programming Boards category; Hi guys ! I have to make a program that rotates the digits in a number with k positions to ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 07:29 PM
  2. how to sum the digits of a number?
    By transgalactic2 in forum C Programming
    Replies: 34
    Last Post: 12-23-2008, 05: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, 04:57 AM
  4. Number of digits in a decimal number
    By maverix in forum C Programming
    Replies: 7
    Last Post: 11-04-2007, 11:12 AM
  5. Number of digits?
    By falador in forum C Programming
    Replies: 2
    Last Post: 05-13-2004, 03:52 AM

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