/******************************************************************************
Problem: Write a program that allow to the user enter a integer
number as input
and show the number in backwords as output.Your program should
include
a loop that lets the user repeat this calculation until the user
says she or he is done.
Course: C++
Tutor: Guillermo Julca
Mercy College
View
Output
******************************************************************************/
//---------------------------------------------------------------------------
#pragma hdrstop
#include <iostream.h>
#include <conio.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
int number;
int Ninv;
int dig;
char ans;
do
{
cout<<"Enter a Number : " ;
cin>> number;
Ninv = 0;
while (number != 0 )
{
dig = number % 10;
number = number / 10;
Ninv = (10 * Ninv ) + dig;
}// end while number != 0
cout<<"The number in backwords is : "<<
Ninv << endl;
cout<<endl;
cout<<"Do you want to continue (Y/N) ?";
cin>> ans;
} while( ans == 'Y' || ans =='y' );
getchar();
return 0;
}
View Output
//---------------------------------------------------------------------------
Copyright © 2002
GJ
GUILLERMO JULCA