#include <iostream.h>
#include <conio.h>
#include<process.h>
void main()
{
int n, u, t, h, r;
cout<<" Enter a number (with 3 digits) ";
cin>> n;
if( n < 100 || n > 999)
{
cout<< "\n It is not a 3 digit no. ! Abort ";
getch();
exit(1);
}
u = n % 10; // digit of unit place
r = n / 10; // remaining two digits
t = r % 10; // digit of tenths place
h = r / 10; // digit of hundredths place
cout<< "\n unit place Digit = " << u;
cout<< "\n ten's place Digit = " << t;
cout << "\n Hundredths place Digit = " << h;
getch();
}
#include
void main()
{
int n, u, t, h, r;
cout<<" Enter a number (with 3 digits) ";
cin>> n;
if( n < 100 || n > 999)
{
cout<< "\n It is not a 3 digit no. ! Abort ";
getch();
exit(1);
}
u = n % 10; // digit of unit place
r = n / 10; // remaining two digits
t = r % 10; // digit of tenths place
h = r / 10; // digit of hundredths place
cout<< "\n unit place Digit = " << u;
cout<< "\n ten's place Digit = " << t;
cout << "\n Hundredths place Digit = " << h;
getch();
}
A good beginner program. Another program demonstrates how to convert a 3 digit number to words - http://mbtechno.blogspot.in/2012/04/c-program-number-in-words.html
ReplyDelete