Monday 8 September 2014

Program to Reverse a Number in Java



Reverse a Number :

Since every digit when divided by 10 gives the remainder equal to the unit place digit of that number and we need to set that unit place digit of number to the last place digit of the number than again set the 100’s digit of that number to the second last place of the given number and so on.

To get the remainder of a number, a modulus (%) operator is used in the program. The program is shown below :

 import java.util.Scanner;  
   
 class ReverseNumber  
 {  
      public static void main(String[] args)  
      {  
           Scanner scan = new Scanner(System.in);  
   
           //scan for the number  
           System.out.println("Enter the number you want to reverse");  
           int n = scan.nextInt();  
   
           //initialize a variable to zero in which we will store reverse no.  
           int reverse = 0;  
   
           //make a while loop till the number will zero  
           while(n != 0)  
           {  
                //first multiply the reverse no. with 10 to shift its digit to next place  
                reverse = reverse * 10;  
                //add the remainder of number/10 to the reverse no.  
                reverse = reverse + n%10;  
                  
                //divide the number by 10 to reduce its one place  
                n = n/10;  
   
                //if n==0 than exit from the loop else repeat  
           }  
   
           //print the reverse number  
           System.out.println("The reverse number is "+reverse);  
      }  
 }  

Output :



In this program we repeatedly find the remainder or unit digit of number by modulus operation with 10 and than reduce the digits by dividing  the number with 10  to get the next unit digit of the given number.

147 comments :

  1. Nice post and thanks for share any way . I want you to visit the link below to get some useful info like BT helpline Customer Care Number

    ReplyDelete
  2. Nice post java programming information providing thanks for sharing

    rf services

    ReplyDelete
  3. Thank you for this great blog post,TechnologyPartner.in is provied Learn java online & Online java Test .The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms.

    ReplyDelete
  4. I have read your blog. Your blog is really helpful for me to know more about Java technology. I did Java Training in Chennai at TIS academy. Its really useful for me to make a bright future in IT industry.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Hi, great stuff ya. You gave the description with good examples. It is the good thing about this blog. And in this Java Programming website, i really found some great knowledge about Java Language. Thank You.

    ReplyDelete
  7. This Blog is very useful. By the way I came across another Java Blog with best info www.java652.com

    ReplyDelete
  8. This Blog is very useful. By the way I came across another Java Blog with best info www.java652.com

    ReplyDelete
  9. It’s not alone you. By now, almost all programmers have done the same, and today are successful professionals in the IT industry. Count them as inspiration and also consider JAVA Training at UrbanPro for more insight.

    ReplyDelete
  10. Thanks for sharing this, it is really very useful.
    Genesis Technologies is an IT company in Indorewhich provides the great quality of software services at very affordable rates.

    ReplyDelete
  11. As we heared more and more tips which enable us for writing for the content. But with this especially how the authoritative really nice. I agree with your 3 point include with more images and videos. It will enable the readers without any confused or any other thing and finally cleared with what we are going to tell.

    Back to Original Services Private Limited

    ReplyDelete
  12. Thanks for sharing informtaion about jaba programming, I read your entire post and realize that your post is really informtaive. Such type of post is reallly helpful for those people who want to learn Jaba programming. Apart from this I read another informtaive post for same kind of informtaion. For your further informtaion I am sharing that informtaive post about jaba programming . http://www.ducatindia.com/javatraining/

    ReplyDelete
  13. Hey Gyss Check out this...

    Softpro Learning Center (SLC)is the training wing of Softpro India Computer Technologies Pvt.
    Limited. SLC established itself in the year 2008.
    SLC offer an intensive and extensive range of training/internship programs for B.Tech, BCA, MCA & Diploma students.
    Softpro Learning Center is a best institute in Lucknow extends in depth knowledge of technology like .Net, Java, PHP and Android and also an opportunity to practically apply their fundamentals. SLC’s objective is to provide skilled manpower to support the vast development programs.


    ReplyDelete
  14. Thanks for sharing information about Java Training, I read your entire post and realize that your post is really informative. Such type of post is really helpful for those people who want to learn Java. Apart from this I read another informative post for same kind of information. For your further information I am sharing that informative post about Java Training. http://www.ducatindia.com/javatraining/

    ReplyDelete
  15. Thanks for the amazing post on Java Programming. You can visit here also for more details: Internet Marketing services in Indore

    ReplyDelete
  16. This is my first visit to your blog, your post made productive reading, thank you. Java Training in Chennai

    ReplyDelete

  17. very useful info, and please keep updating........
    Best Online Software Training

    ReplyDelete
  18. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care.As always, we appreciate you confidence and trust in us.

    Java Training in Chennai

    VMWare Training in Chennai

    ReplyDelete
  19. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.i am expecting more updated posts from your hands. Java Training in Chennai | Data Science Training in Chennai

    ReplyDelete
  20. This comment has been removed by the author.

    ReplyDelete
  21. This comment has been removed by the author.

    ReplyDelete
  22. Hey Gyss Very Nice blog, Thanks For Sharing.

    Softpro Learning Center (SLC)is the training wing of Softpro India Computer Technologies Pvt.
    Limited. SLC established itself in the year 2008.
    SLC offer an intensive and extensive range of training/internship programs for B.Tech, BCA, MCA & Diploma students.
    Softpro Learning Center is a best Summer training institute in Lucknow extends in depth knowledge of technology like .Net, Java, PHP and Android and also an opportunity to practically apply their fundamentals. SLC’s objective is to provide skilled manpower to support the vast development programs.

    ReplyDelete
  23. nice blog very informative for more info pls visit here best java training

    ReplyDelete
  24. Very Interesting topic and usefull for every One and if you wants to learn some Core Java Interview Questions

    ReplyDelete
  25. Looking very good blog. I am so thankful to you and expecting more info on Core Java and please do keep sharing on...
    Thank you so much

    ReplyDelete
  26. This is an amazing blog, and it helps students.Thanks for sharing
    Java
    Online Training India

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. Thanks for Sharing a Great Informative Post.
    6 weeks big data hadoop summer training center in delhi provided by Kvch, Delhi. We provide IT trainings based on corporates standards that helps students to be prepare for industries. Kvch offers 6 weeks big data hadoop internship companies in delhi Kvch is one of the best result oriented Hadoop Training Institute in Delhi, offers best practically, experimental knowledge in Hadoop training in Delhi.
    For more Information : https://kvch.in/delhi/big-data-hadoop-live-project-based-6-weeks-training-delhi.html
    G-18, 2nd Floor, Preet Vihar, Delhi-110092
    Email: delhi.trg1@kvch.in
    Contact: +919212260630

    ReplyDelete
  29. Article is Informative and Useful for me. Thanks for Sharing.
    Kvch Delhi is considered among the best 6 Weeks Java Summer Training Center In Delhi. We have 20+ years of expertise in Summer Training in Java. Due to facilitating students with affordable course fee, placement solution and world-class Android summer training to the participants.
    G-18, 2nd Floor, Preet Vihar, Delhi-110092
    Email: delhi.trg1@kvch.in
    Contact: +919212260630, +919212577708

    BEST 6 WEEKS JAVA INTERNSHIP COMPANIES IN DELHI
    BEST JAVA SIX WEEKS PROJECT BASED SUMMER TRAINING IN DELHI

    ReplyDelete
  30. Nice Information.
    If anyone who wants java training in Noida, so i suggest you please join KVCH Java classes.
    Best Java Training Course in Noida

    ReplyDelete
  31. http://freenotestostudy.blogspot.com/2018/07/the-java-programming-language-program.html
    Object-Oriented Software Development
    problem solving
    program design, implementation, and testing
    object-oriented concepts

    ReplyDelete

  32. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it... Java Training in Chennai | RPA Training in Chennai

    ReplyDelete
  33. Great Post!!! I have read your blog and it's very informative & really impressed . Thanks for sharing it. Keep continue your post. Java Training in Chennai

    ReplyDelete

  34. I have read your blog and I gathered some needful information from your blog. Keep update your blog. Java Training in Chennai | Pega Training in Chennai

    ReplyDelete
  35. Thank you for providing useful information and this is the best article blog for the students.learn Python programming training course.
    Python Training in Hyderabad

    ReplyDelete
  36. Thanks for Sharing this.
    If you are searching more information on FindJava Classes in Hyderabad

    ReplyDelete
  37. Very helpful. Thanks for sharing the useful Java Program to reverse a number.
    Web Application Development Company in Coimbatore

    ReplyDelete
  38. Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
    DevOps Training in Bangalore

    DevOps Training in Bangalore

    DevOps Training in Bangalore

    DevOps Training in Marathahalli

    DevOps Training in Pune

    DevOps Online Training-gangboard

    ReplyDelete
  39. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    iphone glass replacement in chennai | iphone battery replacement service in chennai | iphone display replacement service in chennai | Authorized iphone service center in Chennai | apple iphone service center in chennai

    ReplyDelete

  40. Thanks for sharing this valuable information and we collected some information from this blog.
    Summer Training in Noida

    ReplyDelete
  41. This comment has been removed by the author.

    ReplyDelete

  42. nice article for beginners.thank you.
    python tutorial

    ReplyDelete
  43. Thank you for listing your services here. They might be useful for many seekers, who are after learning php and java. Professional Web design services are provided by W3BMINDS- Website designer in Lucknow.
    Web development Company | Web design company

    ReplyDelete
  44. Hiii...Thanks for sharing Great info...Nice Post...Keep move on...
    Best Python Training in Hyderabad

    ReplyDelete
  45. Great blog article informative I liked it

    We are the best piping design course in Hyderabad, India. Sanjary academy Offers Piping Design Course and Best Piping Design Training Institute in Hyderabad. Piping Design Institute in India Piping Design Engineering.
    best Piping Design Course
    piping design course with placement
    pipe stress analysis course in hyderabad
    piping engineering course in hyderabad
    piping stress analysis course
    best Piping Design institute
    best institute of Piping Design Course in India
    Piping Design Course
    Piping Design Course in India­
    Piping Design Course in Hyderabad

    ReplyDelete
  46. I am really impressed by your work, we also work in Auto Reverse from Bounderie . The Stitchmax Provide best embroidery digitizing service, it is a great way to start creating and editing professional embroidery designs on a VERY low budget.

    ReplyDelete
  47. I think you did an awesome job explaining it. Sure beats having to research it on my own. Thanks
    Agra BCom Time Table 2020
    Allahabad BCom Time Table 2020
    Brij BCOM TimeTable 2020

    ReplyDelete
  48. I need to to thank you for your time due to this fantastic read!! I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
    Java Training in Bangalore

    ReplyDelete
  49. Nice information, valuable and excellent in Job, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
    mobile phone repair in Novi
    iphone repair in Novi
    cell phone repair in Novi
    phone repair in Novi
    tablet repair in Novi
    ipad repair in Novi
    mobile phone repair Novi
    iphone repair Novi
    cell phone repair Novi
    phone repair Novi

    ReplyDelete

  50. This is good information and really helpful for the people who need information about this.
    Java Training in Delhi
    Java Course in Delhi

    ReplyDelete
  51. I am another customer of this site so here I saw various articles and posts posted by this site,I curious more energy for some of them trust you will give more information further.

    360DigiTMG

    ReplyDelete
  52. Its most perceptibly horrendous piece was that the item just worked spasmodically and the data was not exact. You unmistakably canot confront anyone about what you have found if the information isn't right.https://360digitmg.com/course/project-management-professional-pmp

    ReplyDelete
  53. I see some amazingly important and kept up to length of your strength searching for in your on the site
    big data analytics training in malaysia

    ReplyDelete
  54. I have a strategic I'm seconds ago chipping away at, and I have been at the post for such data
    difference between analysis and analytics

    ReplyDelete
  55. These musings just knocked my socks off. I am happy you have posted this.
    training provider in malaysia

    ReplyDelete
  56. Happy to visit your blog, I am by all accounts forward to more solid articles and I figure we as a whole wish to thank such huge numbers of good articles, blog to impart to us.
    hrdf contribution

    ReplyDelete
  57. This comment has been removed by the author.

    ReplyDelete
  58. Here is the site(bcomexamresult.in) where you get all Bcom Exam Results. This site helps to clear your all query.
    BA 3rd year Result 2019-20
    Shivaji University B.Com 6th Semester Result 2020

    ReplyDelete
  59. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!
    Best Data Science Courses in Hyderabad

    ReplyDelete
  60. very interesting post.this is my first time visit here.i found so many interesting stuff in your blog especially its discussion..thanks for the post!
    Best Data Science Courses in Hyderabad

    ReplyDelete
  61. Thank you for providing us Program to Reverse a Number in Java. We are technology/news/smartphone company, If you want to read such useful news then, Visit us: https://techmie.com/

    ReplyDelete
  62. I have read your article, it is very informative and helpful for me. I admire valuable information you offer this articles. Thanks for posting it. Flutter App Development Services

    ReplyDelete
  63. This is the first time I am visiting your website. I would like to tell you that I am genuinely engaged by reading your blogs. Keep up the good work! React Native App Development Services

    ReplyDelete
  64. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging ! Flutter App Development

    ReplyDelete
  65. Your blog post is very interesting. Your level of thinking is good and the clarity of writing is excellent. I enjoyed so much to read this post ! Flutter App Development Services

    ReplyDelete
  66. Does your website have a contact page? I'm having trouble locating it but, I'd like to shoot you an email. I've got some suggestions for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it grow over time.
    app entwickeln lassen berlin

    ReplyDelete
  67. Incredibly conventional blog and articles. I am realy very happy to visit your blog. Directly I am found which I truly need. Thankful to you and keeping it together for your new post.
    data analytics training in yelahanka

    ReplyDelete
  68. I am a regular reader of your blog, Amazing content with proper examples. Thank you admin.

    healthy keto diet plan

    ReplyDelete
  69. This Is Most Useful And Give More Knowledge For Me And Let Me Share It For Alot Of People. And Dont Forget Ti Visit Me Back
    Java course in Nagpur thanks .

    ReplyDelete
  70. Great Content. It will useful for knowledge seekers. Keep sharing your knowledge through this kind of article.
    Node JS Training in Chennai
    Perl Training in Chennai

    ReplyDelete
  71. Thank you for the useful blog. It's very interesting. Share more updates.

    Spoken English Classes In T Nagar
    Spoken English Classes In Porur


    ReplyDelete
  72. It's remarkable. The way you describe the information is awesome. This will really help me out. Thanks for sharing.
    Data Science Training in Chennai
    Data Science Online Training
    Data Science Training in Coimbatore

    ReplyDelete
  73. I really enjoy the blog article.Much thanks again.
    Visit us: Dot Net Online Training
    Visit us: Dot Net Online Course

    ReplyDelete

  74. Great blog!!! The information was more useful for us... Thanks for sharing with us...
    Benefits of .net Framework
    Features of Dot Net

    ReplyDelete
  75. This comment has been removed by the author.

    ReplyDelete
  76. wesome article! You are providing us very valid information. This is worth reading. Keep sharing more such articles. Get All JAVA Tutorials In one place , Thank you very much! ❤❤❤

    ReplyDelete
  77. very informative blog and useful article thank you for sharing with us .
    Visit us: Java Training
    Visit us: Java Course

    ReplyDelete
  78. Java is a high-class object-oriented computer language.
    This makes me curious to learn and I am searching for information about java training in Kolkata and I saw your post.
    It gives me so much information, thanks for sharing.

    ReplyDelete
  79. Very Helpful information for the general public, If you're interested an online cake decorating tutorials then visit us:
    Cake decorating
    Cake decorating

    ReplyDelete
  80. This blog helps me to get valuable information thanks for this informative blog.
    oracle training in chennai
    oracle online course
    oracle training in Coimbatore

    ReplyDelete
  81. This comment has been removed by the author.

    ReplyDelete
  82. Great post shared I really need this post your blog is very useful to me. Visit my website to get best Information About Best IAS coaching Centre in Borivali.
    Best IAS coaching Centre in Borivali
    Top IAS coaching Center in Borivali

    ReplyDelete
  83. Program to Reverse a Number in Java

    Good post for Java developers & students.....!

    Students can learn & try this program...

    Well, read our blog Top 5 Benefits of Hiring Java Development Company for Your Business

    Java Development Company

    ReplyDelete
  84. Great Post. Very informative. Keep Sharing!!

    Apply Now JAVA Training in Noida
    For more details about the course fee, duration, classes, certification, and placement call our expert at 70-70-90-50-90

    ReplyDelete
  85. Thanks for Sharing This Article. Assignment Writing Service is a website that allows you to Online Assignment Help online. Easily to write, Assignment Help Online with trained male and female teachers in Online Classes For Indian Students..

    ReplyDelete
  86. Great blog, Keep writing such informative blogs, I am a regular reader of your blogs. Students searching for industry expert training and guarnteed placement assistance, can aplly in Ducat for best dot net training. Call now on 7070905090.

    ReplyDelete
  87. This blog is quiet interesting and best portion is the new information you provide to readers. Thank you for sharing such information with us. I'm going to bookmark this site for future update.

    For Java Training visit here - incapp

    ReplyDelete
  88. We are the best Share Market training academy in Chennai, offering Tamil market training with technical analysis. Enroll now for stock market classes.for more details contact us: +91 95858 44338, +91 95669 77791

    ReplyDelete
  89. This comment has been removed by the author.

    ReplyDelete
  90. THANK YOU for this amazing and for sharing this blog with us, it is very helpful.
    please keep updated us more about like this type of blog.
    If someone is looking for the best java training institute for software training in Ghaziabad, java training institute
    It is the best place from where you get the practical knowledge of java training institute here. You will be an expert in this field after doing the java training.

    ReplyDelete

  91. Thank you, This was the best and most interesting course. please continue to share your thoughts.

    RPA Course in Chennai
    RPA Online Course
    RPA Course In Bangalore

    ReplyDelete
  92. This is really a helpful blog I am really impressed with your work, keep it up the good work
    1Z0-900: Java EE 7 Application Developer

    ReplyDelete
  93. Superb blog. When I saw Jon’s email, I know the post will be good and I am surprised that you wrote it man!
    We are the best Share Market training academy in Chennai, offering best stock market trading and technical analysis training online & live classes. Enroll now for share market classes by today.for more details contact us: +91 95858 44338, +91 95669 77791

    ReplyDelete
  94. Awesome Article Thanks for sharing your valuable information Hire Java developer from Technoduce Dedicated resource for Java development

    ReplyDelete
  95. Learn Java programming like a pro with the help of our simplified tutorials, examples and frequently asked Java interview questions and answers. Java tutorial for beginners and professional java developers!best java coaching in lucknow

    ReplyDelete
  96. Nice Post! Thanks for sharing such an amazing article, really informative, it helps me a lot.
    1Z0-819: Oracle Java SE 11 Developer
    1Z0-829: Oracle Java SE 17 Developer

    ReplyDelete
  97. I would like to thank you for the efforts you had made for writing this wonderful piece of writing.
    Excellent article for the people who need information about this course.
    Java Training

    ReplyDelete
  98. This is an awesome post. Really very informative and creative contents. Visit my website to get best Information About Modular kitchen in Ghaziabad.
    Modular kitchen in Ghaziabad
    Modular Kitchen in Noida

    ReplyDelete
  99. Thank you for sharing a nice content. Keep sharing and inspiring people, For more skill and digital growth, please check Digital marketing institute in Noida

    ReplyDelete
  100. Great blog, Keep writing such informative blogs, I am a regular reader of your blogs. Thanks for posting.
    5 Steps To Transition From Manual To Automation Testing

    ReplyDelete
  101. Thanks for your post! It was an interesting read that explained the topic really.
    Java Course in Nagpur

    ReplyDelete
  102. This comment has been removed by the author.

    ReplyDelete
  103. informative blog , keep posting and dont forget to checkout our blog java classes in satara

    ReplyDelete
  104. Assignment Help Canberra understands the importance of originality. Their work is plagiarism-free, and they provide proper citations, ensuring the academic integrity of the assignments.
    Java Assignment Help

    ReplyDelete
  105. Get expert assistance with humanities assignment help. Our service provides comprehensive support for topics including history, literature, philosophy, and more. Our team of humanities specialists offers guidance, research assistance, and customized solutions to ensure your assignments meet academic standards and reflect a deep understanding of the humanities disciplines.

    ReplyDelete