Example 50: Paper Sizes
Explore how to implement recursion in C programming to compute paper sizes from A0 to A3. Understand the dimensional rules of A-series papers, apply recursive functions, and manage input-output formatting for dimensions. This lesson helps you practice recursion by solving a real-world problem involving paper sizes.
We'll cover the following...
We'll cover the following...
Problem
The paper of size A0 has dimensions 1189 mm x 841 mm. Therefore, each subsequent size A(n) is defined as A(n-1) cut in half parallel to its shorter sides.
Write a program that takes the parameters given below and displays the dimensions of A0 to A3-sized papers on the console.
- Smallest paper size: 0
- Greatest paper size: 4 (A4 won’t be included)