Example 5: Calculate the Dimensions of a Paper Given the Size
Learn how to calculate the size of various types of paper and print them.
We'll cover the following
Problem
The paper of size A0 has dimensions 1189 mm x 841 mm. Each subsequent size A(n) is defined as A(n-1) cut in half parallel to its shorter sides.
Write a program that takes A0 paper size as a parameter and print sizes of A0, A1, A2, and A3 on the console.
Example
Size of A0 Paper: Height = 1189, Width = 841
Size of A1 Paper: Height = 841, Width = 594
Size of A2 Paper: Height = 594, Width = 420
Size of A3 Paper: Height = 420, Width = 297
Try it yourself
Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.
❗Note: Do not change the print statement given in the exercise below.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.