Thread: reverse a number digits

  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
    39,659
    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.

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, 09:42 AM
  3. Printing a specific number of digits
    By JizJizJiz in forum C++ Programming
    Replies: 4
    Last Post: 06-28-2006, 08:14 PM
  4. values with fixed number of digits
    By silk.odyssey in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 02:01 PM
  5. Count Number of Digits in and Integer
    By redneon in forum C++ Programming
    Replies: 2
    Last Post: 08-18-2003, 04:16 PM