Minggu, 03 Juli 2011

c program reverse number

Reverse function code
#include<stdio.h>
#include<conio.h>
#include<math.h>
long int rev (int);
void main() //rev=function//
{
int num,reverse;
clrscr();
printf("enter the numbet");
scanf("%d",&num);
reverse=rev(num);
printf("rev of %d is %d" , num,reverse);
getch();
}
long int rev(int x)
{
int r;
long int rev=0;
while(x!=0)
{
r=x%10;
rev=rev*10+r;
x/=10;
}
return(rev);
}

Tidak ada komentar:

Posting Komentar