About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Saturday, August 31, 2013

C Program to reverse a given number !

#include<stdio.h>
#include<conio.h>

void main()
{
int num,rem,rev=0;
clrscr();

printf("Enter any no to be reversed : ");
scanf("%d",&num);

 while(num>=1)
    {
    rem = num % 10;
    rev = rev * 10 + rem;
    num = num / 10;
    }

printf("Reversed Number : %d",rev);
getch();
}
Output :
Enter any no to be reversed : 123
Reversed Number : 321

No comments: