printing contents of array vertically
Hi,
I have written a program from a book I'm learning from. Everything works except for the end when the contents of an array is to be displayed in a table.
Code:
#include <stdio.h>
main()
{
int sweatshirts[7][4],
size, /*index*/
college; /*index*/
for(college=0; college<7; ++college)
{
printf("\nPlease enter the number of sweatshirt sizes for college %d." , college+1);
for(size=0; size<4; ++size)
{
printf("\nSize(%d): " , size+1);
scanf("%d" , &sweatshirts[college][size]);
}
}
for(college=0; college<7; ++college)
{
for(size=0; size<4; ++size)
{
printf("\n%d " , sweatshirts[college][size]);
/*this loop is just to test the output numbers are correct*/
if(size == 3)
printf("\n");
}
}
/*output numbers will go in this table in columns under 1-7*/
/*printf("\n College \n");
printf("\n 1 2 3 4 5 6 7 Size total ");
printf("\n");
printf("\n Small\n");
printf("\n Medium\n");
printf("\nSize\n");
printf("\n Large\n");
printf("\n X_Large\n");
printf("\nCollege total\n");
printf("\nTotal quantity on hand\n"); */
}
The table is on the bottom in /*comments*/. The last for loop is just a test to see if the output is correct. But it will eventually be in the table. Problem is I cant get each "size" for each of the 7 "stores" to print out vertically under each numbered column like:
1 3
2 4
3 5
4 6 I have tried using /t in the for loop to try and make the numbers start in a new position to the right, but no luck.