Example 50: Paper Sizes

Learn how to calculate the size of various types of paper and then print them.


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)
  • A0 length
  • A0 Width


Input Output
0, 4, 1189, 841 1189,841 841,594 594,420 420,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.

Note: While printing, the dimensions of a paper should be comma-separated, and each type of paper should be space-separated like given below:

1189,841 841,594

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.