To display a table, simply use column and row variables, display each column, and then issue a printf("\n");
To make your columns a fixed length, for example 4, instead of doing a "%d" in the format string do a %4d". If you are doing floats and want say 5 figures of whole numbers and 2 decimal places, "%5.2f".
In other words this is very straightforward.
How to display a 2 dimensional array in columns using C?
for(i=0;i%26lt;rows;i++)
{
for(j=0;j%26lt;columns;j++)
{
printf("\t%d",x[i][j]);
}
printf("\n");
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment