Make an 8x8 matrix of integers, then set each value as follows. 8 7 6 5 4 3 2 1
ID: 3922357 • Letter: M
Question
Make an 8x8 matrix of integers, then set each value as follows.
8 7 6 5 4 3 2 1
16 15 14 13 12 11 10 9
24 23 22 21 20 19 18 17
32 31 30 29 28 27 26 25
40 39 38 37 36 35 34 33
48 47 46 45 44 43 42 41
56 55 54 53 52 51 50 49
64 63 62 61 60 59 58 57
Print the matrix so that the columns line up, using at least 2 places for each value, at least 1 space between each column, and a new-line after each row.
Here is my code:
int main ()
{
int T[10][10],l,c,i;
l=10;
c=10;
for(int j=0;i<l;i++){
printf(" ");
for(int j=0;j<c;j++){
printf(T[i][j]);
}
}
return 0;
}
Explanation / Answer
#include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=8;i++)
{
for(j=i*8;j>8*(i-1);j--)
{
if(j<i*8)
{
printf(" ");
}
if(j<10)
{
printf(" ");
}
printf("%d",j);
}
printf(" ");
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.