Tuesday, 4 October 2011

Reverse a number in C language

/* This program will reverse the integer input by the user... And this is one of the example of do...while loop*/



#include<stdio.h>
#include<conio.h>
void main()
{
int a,s=0,i=0,r=0;
clrscr();
printf("Enter the number : ");
scanf("%d",&a);
i=a;
do
{
     r=i%10;
     s=s*10+r;
     i=i/10;
}while(i>=1);
printf("The reverse of the number %d is = %d",a,s);
getch();
}

// Happy Programming......//

No comments:

Post a Comment