Computer Science, asked by mishratn924, 1 month ago

Input a 2 digit number and print reverse of the number(flowchart)​

Answers

Answered by angadyawalkar09
0

ATechDaily

Home(current)

Categories

Tools

Contact

About

Write For Us

Login

 

Algorithm and Flowchart to Print the Reverse of the Number

[36718 views]

What is meant by Reversing the number?

If we took a number 4567 then the reverse of the number should be 7654.

What is use of Reversing of the number?

It's very important and is use to recognize the pattern. We use this concept to check or create palindromes.

What should be the approach for this program ?

In this program we will be using the concept of ones tens hundreds and thousand places place value system. Like if 1234 a number is given then we can find the number by taking the remainder and multiplying the number by 10 to shift its place by one unit like remainder is 1 then 10+2 , 120+3 , 1230+4 we get that number. So for finding the reverse of the number we will be using the same concept.

 

Flowchart for Reversing the Number

Flowchart to Print the Reverse of the Number

Remove WaterMark from Above Flowchart

Algorithm for Reversing the Number

Declare a variable n, reverse and remainder as integer;

Read the number n;

while n not equal 0

{

   remainder=n%10;

   reverse=reverse * 10 + remainder;  

   n=n/10;

}

Print reverse

Here in this algorithm we declare 3 variables n to store the integer , remainder to find the last digit and reverse for storing the result. So in this algorithm read the number let's say 4536 then we enter the while loop as n is not equal 0.Then we use modulo to find the last digit and in reverse we multiply the reverse * 10 and add it.

In the first iteration remainder=6 and reverse = 0 * 10 + 6 and n become

Similar questions