Initial Basics – Algebra – Problem #18
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Difficulty: medium
Problem Statement
Write a program that takes an integer number between 1 and 100 as input, and then displays the value of the input in words. Some sample inputs and outputs are: Input: 13 Output: Thirteen Input: 56 Output: Fifty six Output: Ninety eight Note that, a brute force method is to write 100 if-else statements. But, this will fetch you only 75% marks. This problem can be solved using far less number of conditional statements, by utilizing the fact that the word representations of numbers between 20 and 99 follow a pattern.