This Program will reverse a numbers in C++. For example a user will enter a number 12346 then the program will show the number like 64321.
Source Code
#include<iostream> using namespace std; int main() { int num1 = 0; int num2 = 0; cout<<" \t \t \t LEP Tutorials \n \n \n "; cout<<" Enter Your Number : "; cin>>num1; for( ; num1!= 0 ; ) { num2 = num2 * 10; num2 = num2 + num1%10; num1 = num1/10; } cout<<" Reversed Number : "<<num2; return 0; }
0 comments:
Post a Comment