Q: 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 to calculate and print paper sizes A0, A1, A2, ….. A8.
#include<stdio.h>
int main()
{
int i, w=841, h=1189, k;
for(i=0; i<9; i++)
{
printf("\n A%d: %d x %d", i, w, h);
k = h;
h = w;
w = k/2;
}
return 0;
}
-----------------------------------------
Output:
A0: 841 x 1189
A1: 594 x 841
A2: 420 x 594
A3: 297 x 420
A4: 210 x 297
A5: 148 x 210
A6: 105 x 148
A7: 74 x 105
A8: 52 x 74
int main()
{
int i, w=841, h=1189, k;
for(i=0; i<9; i++)
{
printf("\n A%d: %d x %d", i, w, h);
k = h;
h = w;
w = k/2;
}
return 0;
}
-----------------------------------------
Output:
A0: 841 x 1189
A1: 594 x 841
A2: 420 x 594
A3: 297 x 420
A4: 210 x 297
A5: 148 x 210
A6: 105 x 148
A7: 74 x 105
A8: 52 x 74
Comments
Post a Comment