This Post Contains A C++ Program For Conversion Of Integers/Numbers Into Words With Correct Source Code & Output. This Program Is Written, Compiled & Executed At TurboC3.0 Compiler & Will Help You To Understand The Concept Of 'Arrays', 'If...else' & 'For-Loop' From C++ Language. It Is A Well-Structured Program With Proper Comments Which Provides Step-By-Step Description Of Various Features Of The Language In A Simple & Easy-To-Understand Way.
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C++ Program For Conversion Of Integers/Numbers Into Words.
# include < iostream.h >
# include < conio.h >
void main ()
{
char a[10][10] = { "One" , "Two" , "Three" , "Four" , "Five" , "Six" , "Seven" , "Eight" ,
"Nine" , "Ten" };
char b[10][13] = { "Eleven" , "Twelve" , "Thirteen" , "Fourteen" , "Fifteen" , "Sixteen" ,
"Seventeen" , "Eighteen" , "Nineteen" };
char c[10][10] = { "Ten" , "Twenty" , "Thirty" , "Forty" , "Fifty" , "Sixty" , "Seventy" ,
"Eightty" , "Ninty" , "Hundred" };
int r , s, t;
long n;
clrscr();
/* Enter Any No. Below 1 Lakh */
cout << " Enter Any Number :- ";
cin >> n;
if ( n > 9999 )
{
r = n / 1000;
if ( r > 10 && r < 20 )
{
r = r % 10;
cout << b[ r-1 ] << " Thousands ";
}
else
{
s = r / 10;
t = r % 10;
cout << c[ s - 1 ];
cout << a[ t - 1 ] << " Thousand ";
}
n = n % 1000;
}
if ( n > 1000 )
{
r = n / 1000;
cout << a[ r - 1 ] << " Thousand ";
n = n % 1000;
}
if ( n > 100 )
{
r = n / 100;
cout << a[ r - 1 ] << " Thousand ";
n = n % 100;
}
if ( n > 10 && n < 20 )
{
r = n % 10;
cout << b[ r - 1 ];
}
if ( n > 19 && n <= 100 )
{
r = n / 10;
cout << c[ r - 1 ];
n = n % 10;
}
if ( n > 0 && n <= 10 )
{
cout << a[ n - 1 ];
}
getch();
}
Output :
/* Enter Any No. Below 1 Lakh */
Enter Any Number :- 1234
One Thousand Two Hundred Thirty Four
Enter Any Number :- 111
One Hundred Eleven
This blog provides an overview about basic structure of C/C++ programs and their execution, which makes it an ideal guidance source for Programmers and Students. Based on practical approach this blog features a wide range of programs, which enables the learner to understand the techniques such as: Simple Programs, Loops, Arrays, Functions, Objects, Operator Overloading, Polymorphism, Files, Graphics, Strings, Sorting and Searching Methods, Stack, Queues, Link-Lists, Trees and Mini-Projects.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2012
(37)
-
▼
December
(11)
- C++ Program To Find NCR Factor.
- C++ Program For Printing ASCII Values On Screen/Co...
- C++ Program For Conversion Of Integers/Numbers Int...
- C++ Program To Print Even Numbers Upto A User-Spec...
- C++ Program To Find & Print An Armstrong Number.
- C++ Program For Conversion Of Decimal No Into Bina...
- C++ Program To Find & Print Twin Prime Numbers.
- C++ Program To Find Prime Factors Of A Number.
- C++ Program To Find Lowest Number Out Of Three Num...
- C++ Program To Find A Factorial Of A Number.
- C++ Program For Conversion Of Fahrenheit To Celsius.
-
▼
December
(11)
No comments:
Post a Comment