W.A.P. C++

WAP | CPP | Programs in C++ | C++ Solutions

Snehil Khanor's Binary Log

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. }

4 comments:

Anonymous June 14, 2012 at 12:09 PM  

how does the while loop works here..???? please tell earlier as possible...!!

Anonymous May 28, 2013 at 12:13 PM  

Thanks.....Nice work

souravamex June 3, 2013 at 9:02 PM  

fata fati... thanks...nice work

hitesh kumar December 13, 2015 at 12:36 AM  

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

Search

About WAP C++

Here you'll find a wide range of programs' solution ranging from beginer level to advanced level.
All programs here are made, compiled and tested by me..and are running absolutely fine.. still if you find any bug in any program do let me know :)

Followers

Subscribe via email

Enter your email address:

Delivered by FeedBurner

my Binary Log

Blog Archive



eXTReMe Tracker