Question: If a five-digit number is input through the keyboard. Write a program to reverse a number.
solution :
Screenshot
source code
#include <iostream>
#include<conio.h>
using namespace std ;
int main()
{
int n;
int rev[6],revn=0;
cout<<"Enter a 5 digit number : ";
cin >>n;
for(int i=1; i<6; i++)
{
rev[i]=n%10;
n=n/10;
}
for(int i=1; i<6; i++)
{
cout<<rev[i];
}
}
No comments:
Post a Comment