Advertisement
athacks

Untitled

Mar 19th, 2014
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(void){
  6.     int num, rem, NumRev = 0;
  7.     char waitInput;
  8.     cout<< "Enter a number between 1 and 9999: ";
  9.     cin>>num;
  10.     if (num < 1 || num > 9999){
  11.         cout << "Error, out of range value!\n";
  12.         return(0);
  13.     }
  14.     while(num)
  15.         {
  16.         rem = num % 10;  //get yer numbers
  17.         NumRev = (NumRev * 10) + rem; //rever'em digitz by digitz
  18.         num = num / 10;    //we dont need the last number
  19.     }
  20.     cout<< "The number with its digits reversed is: " << NumRev << endl;
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement