Reversing digits of an Integer Assignment Help

Assignment Help: >> Algorithms for Problem Solving >> Reversing digits of an Integer

Reversing digits of an integer

 To understand the reversing digits of an integer we take an example. Suppose we take the five digits number from keyboard. For this, we use the modulo (%) operator.

Input: 12345

Output: 54321

So for doing as, we divide five digits number by 10 and take its remainder and print the remainder and quotient is again divided by 10 and take its remainder until the quotient become zero.

Logic:

while(n>0)

{

rem=n%10;

n=n/10;

printf("%d", rem);

}

 

Algorithm:

Step 1: Start

Step 2: Take five digits positive integer to be reversed.

Step 3: Take remainder of given number by the modulo operator.

Step 4: Divide quotient by 10.

Step 5: Repeat step 3 and 4 until n becomes zero.

Step 6. Print the value of remainder.

Step 7: Stop.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd