Hi everyone, hope you're doing well. Im new here so please go easy on me
I am having trouble printing out a table that should look like this
but I end up with much longer table and this is my code for the tableCode:****************************************************************************************| height | base | Cross-sectional area | Moment of inertia | Section modulus | cm | cm | base x height | (base x height^3)/12 | (base x height)/6 | ----------------------------------------------------------------------------------------| 2 | 2 | | | | ----------------------------------------------------------------------------------------- 4 | 2 | | | | ----------------------------------------------------------------------------------------- 6 | 2 | | | | ----------------------------------------------------------------------------------------- 8 | 2 | | | | ----------------------------------------------------------------------------------------- 10 | 2 | | | | ----------------------------------------------------------------------------------------- 12 | 2 | | | | ----------------------------------------------------------------------------------------- 2 | 4 | | | | ----------------------------------------------------------------------------------------- 4 | 4 | | | | ----------------------------------------------------------------------------------------- 6 | 4 | | | | ----------------------------------------------------------------------------------------- 8 | 4 | | | | ----------------------------------------------------------------------------------------- 10 | 4 | | | | ----------------------------------------------------------------------------------------- 12 | 4 | | | | ----------------------------------------------------------------------------------------- 2 | 6 | | | | ----------------------------------------------------------------------------------------- 4 | 6 | | | | ----------------------------------------------------------------------------------------- 6 | 6 | | | | ----------------------------------------------------------------------------------------- 8 | 6 | | | | ----------------------------------------------------------------------------------------- 10 | 6 | | | | ----------------------------------------------------------------------------------------- 12 | 6 | | | | ----------------------------------------------------------------------------------------- 2 | 8 | | | | ----------------------------------------------------------------------------------------- 4 | 8 | | | | ----------------------------------------------------------------------------------------- 6 | 8 | | | | ----------------------------------------------------------------------------------------- 8 | 8 | | | | ----------------------------------------------------------------------------------------- 10 | 8 | | | | ----------------------------------------------------------------------------------------- 12 | 8 | | | | ----------------------------------------------------------------------------------------- 2 | 10 | | | | ----------------------------------------------------------------------------------------- 4 | 10 | | | | ----------------------------------------------------------------------------------------- 6 | 10 | | | | ----------------------------------------------------------------------------------------- 8 | 10 | | | | ----------------------------------------------------------------------------------------- 10 | 10 | | | | -----------------------------------------------------------------------------------------
Code:
- #include<stdio.h>
- int main()
- {
- int z;
- int y;
- int i;
- printf("****************************************************************************************|");
- printf("\n height | base | Cross-sectional area | Moment of inertia | Section modulus\t|");
- printf("\n cm | cm | base x height | (base x height^3)/12 | (base x height)/6 |");
- printf("\n----------------------------------------------------------------------------------------|");
- for(z=1;z<=6;z++)
- {
- for(i=2;i<=10;i+=2)
- for(y=2;y<=12;y+=2)
- printf("\n %d\t| %d\t|\t\t\t|\t\t\t|\t\t\t|\n-----------------------------------------------------------------------------------------",y,i);
- }
- printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- return 0;
- }