Write a Program to Reverse a number in c++ using for loop


#include<iostream> using namespace std; int main(){ int i,num,rev=0,r; cout<<"Enter a number :"<<endl; cin>>num; for(;num>0;){ r=num%10; rev=rev*10+r; num=num/10; } cout<<"The reverse Number By using for Loop is :"<<rev; return 0; }

Output:-

Enter a number :123
The reverse Number By using for Loop is :321