Program to Reverse a number in C language

The following program will show how you can reverse a particular number in C language. The code has been written and compiled in Dev C++.

code:

#include
void main(){
	int n,a,r=0;
	printf("Enter any number: ");
	scanf("%d",&n);
	while(n>=1)
	{
		a=n%10;
		r=r*10+a;
		n=n/10;
		
	}
	printf("Reverse = %d",r);
	
}

OUTPUT:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.