Wednesday 6 July 2011

C programme to reverse a number using while loop

#include <stdio.h>
#include <conio.h>
void main()
{
int n,mod,rev=0;
clrscr();
printf("enter a number");
scanf("%d",&n);
while(n>0)
{
mod=n%10;
rev=rev*10+mod;
n=n/10;
}
printf("%d",&rev);
getch();
}

No comments:

Post a Comment