Menus

Wednesday 1 April 2020

C Program to reverse the number


#include<stdio.h>

int reversenum(int n)
{

int rev=0,a;

while(n>0)
{
a=n%10;
n=n/10;
rev=rev*10+a;
}

return rev;


}


void main()
{

int n,rev;
printf("Enter the number : ");
scanf("%d",&n);

rev = reversenum(n);

printf("The reverse of the number is %d \n",rev);


}





No comments:

Post a Comment