Hi,
this is a school assignment and I am stuck.
I have 3 one dimensional arrays, I think 2 dimensional might be easier, but this is what the assignment calls for.
Now what I have is this:
Code:
main()
{
int x = 0;
int y = 0;
int z = 0;
int empnum[30]={1, 4, 5, 7, 8, 12, 13, 14, 16, 22};
int days[30]={5, 8, 4, 5, 10, 5, 4, 10, 4, 4};
int vehicles[30]={30, 40, 20, 30, 70, 10, 15, 20, 40, 50};
printf("\n Employee #");
printf(" Days");
printf(" Vehicles\n");
for ( x = 0; x < 10;x++ )
{
printf("%8d ", empnum[x]);
for ( y = 0; y < 10; y++ )
{
printf("%8d ", days[y]);
for ( z = 0; z < 10; z++ )
{
printf("%8d ", vehicles[z]);
}
printf( "\n" );
}
}
for (x=0; x<10; ++x)
{
printf("\n Enter Employee Number : ");
scanf("%d", &empnum[x]);
}
for (y=0; y<10; ++y)
{
printf("\n Enter Days : ");
scanf("%d", &empnum[y]);
}
for (z=0; z<10; ++z)
{
printf("\n Enter Number of Vehicles Tested : ");
scanf("%d", &empnum[z]);
}
return 0;
}
It is not final yet, in fact the part I am stuck on is in the very beginning.
Code:
printf("\n Employee #");
printf(" Days");
printf(" Vehicles\n");
for ( x = 0; x < 10;x++ )
{
printf("%8d ", empnum[x]);
for ( y = 0; y < 10; y++ )
{
printf("%8d ", days[y]);
for ( z = 0; z < 10; z++ )
{
printf("%8d ", vehicles[z]);
}
printf( "\n" );
}
}
When I had the printf statments just all by themselves it was lined up perfectly. Of course however all it returned was a row of 0's and not the data in the array. So I tried putting it together in a double nested for loop setup and the outcome is way messed up.
I have messed around with lots of little tweaks, but I can't get a nice looking output.
I have had it where the first two (employee # and days) output ok for one row, and then it outputs the entire vehicles array, then the next row is ok for the first two etc.
Then i have had it where it is all diagonally slanted.
Now I am not even sure what it is doing.
Code:
Employee # Days Vehicles
1 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
7 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
8 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
12 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
13 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
14 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
16 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
22 5 30 40 20 30 70 10 15
20 40 50
8 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
5 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
10 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
4 30 40 20 30 70 10 15 20
40 50
So I am obviously a C noob because I can't figure out how to output a simple 1 dimensional array correctly.
Can anyone give me some insight into what I might be doing wrong?
Thanks