write a program to reverse digits of a number

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 :)



  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. long int n,rev=0,m;
  7. cout<<"please enter a five digit no.: ";
  8. cin>>n;
  9. while(n>0)
  10. //Coding by: Snehil Khanor
  11. //http://WapCPP.blogspot.com
  12. {
  13. m=n%10;
  14. rev=rev*10+m;
  15. n=n/10;
  16. }
  17. cout<<rev;
  18. getch();
  19. }

Check out this stream