C++ Program to Reverse a Number
Here today we write C++ Program to Reverse a Number or Reverse a number program in C++
#include<iostream.h>
#include<conio.h>
void main()
{
int num, reverse = 0;
cout<<"Enter any number: ";
cin>> number;
for( ; num!= 0 ; )
{
reverse = reverse * 10;
reverse = reverse + num%10;
num = num/10;
}
cout<<"Reversed Number is: "<<reverse;
getch();
}
Output:
Enter any number: 345
Reverse Number is: 543
No comments :
Post a Comment