C PROGRAMMING

write a c progam to reverse a given number using function

#include<stdio.h>
#include<conio.h>
//REVERSE NUMBER USING FUNCTION
void rev(int);
void main()
{
int num;
printf("enter any numbern");
scanf("%d",&num);
rev(num);
getch();
}
void rev(int n)
{
int rev=0,r;
while(n!=0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
printf("reversed number=%d",rev);
}

Related Articles

Leave a Reply

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

Back to top button