Reverse a Number in C

Reverse a Number in C

In this program, You will get and learn the program code of Reverse a Number in C programming. This program is briefly explain with algorithm, DFD (Data Flow Diagram), and program code.

Here you will know to create Reverse a Number program by using 3 different kinds of methods.

Reverse a Number in C

 

How to Reverse a Number

The reverse number is a mathematical operation where the digits of a number are reversed from the backyard. For example, if the number is 12345, the reverse number would be 54321.

Reverse Number Algorithm

Step 1. Input number from user.

Step 2. Get the remainder, quotient of number, by dividing 10.

Step 3. Multiply result variable by 10, then Add remainder in that.

Step 4. Replace number by quotient.

Step 5. Repeat Step 2,3,4 till then number is greater then 0.

Step 6. Print result variable value as reverse number.

Reverse a Number DFD(Data Flow Diagram)

reverse a number DFD

Reverse a Number in C using 3 different ways

#1. Reverse Number in C using while loop

#2. Reverse Number in C using functions

#3. Reverse Number in C using recursion

 

Reverse a Number in C using while loop

Output

c program to reverse number using while output

 

Reverse a Number in C using Functions

Output

c program to reverse number using functions output

Reverse a Number in C using Recursion

Output

c program to reverse number using recursion output

Program Explanation

1. Take the input integer number and store it in integer num variable.

2. divide num by 10, and obtain quotient and remainder.

3. Multiply result variable by 10 and add remainder.

4. replace num variable value by quotient.

5. repeat process until num not got zero.

6. Print the value of variable result as reverse of number.

 

 

Check out our other C programming Examples

 

 

 

Leave a Comment

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

Scroll to Top