Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(void){
- int num, rem, NumRev = 0;
- char waitInput;
- cout<< "Enter a number between 1 and 9999: ";
- cin>>num;
- if (num < 1 || num > 9999){
- cout << "Error, out of range value!\n";
- return(0);
- }
- while(num)
- {
- rem = num % 10; //get yer numbers
- NumRev = (NumRev * 10) + rem; //rever'em digitz by digitz
- num = num / 10; //we dont need the last number
- }
- cout<< "The number with its digits reversed is: " << NumRev << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement