A number is taken from the user number with reverse digits is displayed
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- long int n,rev=0,m;
- cout<<"please enter a five digit no.: ";
- cin>>n;
- while(n>0)
- //Coding by: Snehil Khanor
- //http://WapCPP.blogspot.com
- {
- m=n%10;
- rev=rev*10+m;
- n=n/10;
- }
- cout<<rev;
- getch();
- }
4 comments:
how does the while loop works here..???? please tell earlier as possible...!!
Thanks.....Nice work
fata fati... thanks...nice work
C++ Program to Reverse a Number
Reverse of number means reverse the position of all digits of any number. For example reverse of 536 is 635
Post a Comment