//with return value, with argument .. reverse number
#include<stdio.h>
#include<conio.h>
int rev(int);
void main()
{
int revno, no;
clrscr();
printf("\nEnter number: ");
scanf("%d", &no);
revno = rev(no);
printf("\nReverse number = %d", revno);
getch();
}
int rev(int no)
{
int rem, revno=0;
while(no > 0)
{
rem = no % 10;
revno = revno * 10 + rem;
no = no / 10;
}
return revno;
}
No comments:
Post a Comment