Hello Devs,

In this tutorial, we are going to learn C program to find reverse of a number

Here is a well-commented example you can understand and analyze.

#include <stdio.h>
int main(){
    int num,r,reverse=0;

    printf("Enter any number: ");
    scanf("%d",&num);

    while(num){
         r=num%10;
         reverse=reverse*10+r;
         num=num/10;
    }

    printf("Reversed of number: %d",reverse);
    return 0;
}

C program to reverse a number using for loop

#include <stdio.h>
int main(){
    int num,r,reverse=0;

    printf("Enter any number: ");
    scanf("%d",&num);

    for(;num!=0;num=num/10){
         r=num%10;
         reverse=reverse*10+r;
    }

    printf("Reversed of number: %d",reverse);
    return 0;
}


I hope this example helps you.