here is the code in c++ on how to reverse the number input by the user.
#include "stdafx.h"
#include<iostream>
using namespace std;
int main() {
int number, reverse_num = 0;
cout<<"Input a Number to Reverse:";
cin>> number;
for(;number!= 0 ; ) {
reverse_num = reverse_num * 10;
reverse_num = reverse_num + number%10;
number = number/10;
}
cout<<"Reversed Number is: "<<reverse_num;
cin.get();
cin.get();
return 0;
}
No comments:
Post a Comment