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.

Back to Lab Problems
Initial Basics/Algebra/Problem #18

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #18

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.