@return the name of the number (e.g. “two hundred seventy four”) 67




Download 90,96 Kb.
bet6/6
Sana22.02.2024
Hajmi90,96 Kb.
#160738
1   2   3   4   5   6
Bog'liq
1.1amaliy ish

66@return the name of the number (e.g. “two hundred seventy four”)
67 */
68 string int_name(int number)
69 {
70int part = number; // The part that still needs to be converted
71string name; // The return value
72
73if (part >= 100)
74 {
75name = digit_name(part / 100) + « hundred»; 76part = part % 100;
77 }
78
79if (part >= 20)
80 {
81name = name + « « + tens_name(part);
82part = part % 10;
83 }
84else if (part >= 10)
85 {
86name = name + « « + teen_name(part);
87part = 0;
88 }
89
90if (part >0)
91 {
92name = name + « « + digit_name(part);
93 }
94
95return name;
96 }
97
98int main()
99 {
100 cout <<«Please enter a positive integer: «; 101int input;
102 cin >> input;
103 cout << int_name(input) << endl;
104return0;
105 }
program run
Please enter a positive integer: 729
seven hundred twenty nine
Download 90,96 Kb.
1   2   3   4   5   6




Download 90,96 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa



@return the name of the number (e.g. “two hundred seventy four”) 67

Download 90,96 Kb.