Showing posts with label reverse. Show all posts
Showing posts with label reverse. Show all posts

Monday, February 16, 2015

C program to reverse a number

C++ program to reverse a number

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr(); //to clear the screen
long n,rev=0,d;
cout<<"Enter the number:";
cin>>n;

while(n!=0)
{
d=n%10;
rev=(rev*10)+d;
n=n/10;
}

cout<<"The reversed number is "<<rev;
getch(); //to stop the screen
}
Read more »