reverse a number digits

This is a discussion on reverse a number digits within the C++ Programming forums, part of the General Programming Boards category; Write program that reverse a number digits. The program will ask the user to enter a number (one variable) consist ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    3

    reverse a number digits

    Write program that reverse a number digits. The program will ask the user to enter a number (one variable) consist from three digits then the program reverse the digits of the number.
    Note: you must define the number as integer. To solve the problem use the / and the %

    The program output might be like this

    Enter any number consist from three digits = 123
    The reverse of this number= 321

  2. #2
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    Don't quote me on that... ...seriously

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Marked in red is what you need to figure out. Even with the omissions, someone will probably cyber-whip me for helping you this much.

    Code:
    #include <iostream>
    
    
    int main ()
    {
    short x;
    
    std::cout<<"enter a number";
    std::cin>>x;
    
        short a=(x&#37;10);
        short b=(?%?)?10;  
        short c=(x/?);
    
    std::cout<<?<<?<<?<<std::endl;
       
        std::cin.ignore();
    	std::cin.get();
    
        
        return 0;
    }

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    Yup, that's about as far as you can go without giving the whole game away
    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. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-21-2009, 12:37 AM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 10:42 AM
  3. Printing a specific number of digits
    By JizJizJiz in forum C++ Programming
    Replies: 4
    Last Post: 06-28-2006, 09:14 PM
  4. values with fixed number of digits
    By silk.odyssey in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 03:01 PM
  5. Count Number of Digits in and Integer
    By redneon in forum C++ Programming
    Replies: 2
    Last Post: 08-18-2003, 05:16 PM

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