In this tutorial, we will write a reverse number in C using for loop. Before that, you may go through the following topics in C.
C program to reverse a number using for loop
This is a reverse number program in C using for loop where the program takes the input from the user. And then iterating through for loop, the program calculates the reverse of a number and then finally displays the result.
int num, rev = 0, rem;
printf("Enter the Number: ");
for (; num != 0; num = num / 10)
rem = num % 10;
rev = rev *10 + rem;
printf("Reversed number: %d", rev);
Enter the Number: 1234
Reversed number: 4321
As you can see the initialization part in for loop is left empty and only the condition checking and increment/decrement is filled within “()” in reverse number in c using for loop.