Skip to content
DATA STRUCTURE
DATA STRUCTURE

Learn everything about Data structure

  • Algorithms
  • DSA
  • Array
  • Stack
  • Queue
  • Matrix
  • Programs
DATA STRUCTURE

Learn everything about Data structure

Algorithm to reverse a given number

YASH PAL, September 25, 2022March 6, 2023

In this tutorial, we are going to write an Algorithm to reverse the digits of given n-digit numbers. using this algorithm we can write a program to reverse the digits of given n-digit numbers or a number in almost most programming languages like java python c++ and c programming.

[br]

Algorithm to reverse a given number.

1. Read N.
2. Set REV:=0.
3. Repeat steps 5 and 6 while N>=0.
4. Set N:=N/10.
5. Set REV:=REV*10 + remainder.
6. Print the value of REV.
7. Exit.
[br]
Here in the above algorithm first we read an integer variable N and then set the default value of another variable to 0. and then using the while loop we repeat steps 5 and 6. in the 4th step we set the value of N to N/10 and then set the value of REV variable to REV*10 + remainder. we will repeat these two steps till the value of N is become equal to or less than 0. and then we print the value of the REV variable and then Exit from the program.
[br]
Also, Read
  1. Algorithm to Find Maximum of Two Numbers
  2. Algorithm to Find Maximum of Three Numbers
  3. Algorithm to Input percentage From user and Print grade
  4. Algorithm to Print the Series 1 to N using for loop
  5. Algorithm to Print the Series 1 to N using while loop
  6. Algorithm to Print the Series 1 to N using Do While loop
  7. Algorithm to Find Whether a Number is Prime or Not
  8. Algorithm for Linear Search in Array
  9. Algorithm to Calculate Factorial using Function
algorithms algorithm

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

  • HackerRank Dynamic Array Solution in Python
  • HackerRank 2D Array DS solution in Python
  • HackeRank Array – DS solution in Python
  • Streaming Demystified: How Much Data Does Your Favorite Show Really Use?
  • Parenthesis Matching program in C programming
  • HackerRank Dynamic Array Solution in Python
  • HackerRank 2D Array DS solution in Python
  • HackeRank Array – DS solution in Python
  • Streaming Demystified: How Much Data Does Your Favorite Show Really Use?
  • Parenthesis Matching program in C programming
  • About US
  • Contact US
  • Data Structures and algorithms tutorials
  • Digital Communication Tutorials
  • DMCA
  • HackerRank All Algorithms problems solutions
  • HackerRank C problems solutions
  • HackerRank C++ problems solutions
  • HackerRank Java solutions
  • HackerRank Python solutions
  • Human Values Tutorials
  • Internet of Things Tutorials
  • Privacy Policy
©2025 DATA STRUCTURE | WordPress Theme by SuperbThemes