I have a problem with my c language lesson, Its about multiplication table made in c language particularly arrays. So, how can i make it? i tried to do it and the only thing appears are the numbers from 1-10 vertically and horizontal as well...and not the table anymore.
im looking forward to your answers guys.... thanks alot!
C Language-arrays?
change
for (row = 1; row %26lt;= 10; row++) {
// for each column 1 to 10 ...
for (col = 1; col %26lt;= 10; col++) {
by
for (row = 0; row %26lt; 10; row++) {
// for each column 1 to 10 ...
for (col =0; col %26lt; 10; col++) {
in above program
Reply:My syntax might not be correct (it's been a while since I used C) but here it goes,
void main (void) {
// mult[][] will be a 2 dimensional array containing your table
int mult[10][10];
int row = 1, col = 1;
// for each row 1 to 10 ...
for (row = 1; row %26lt;= 10; row++) {
// for each column 1 to 10 ...
for (col = 1; col %26lt;= 10; col++) {
// store the product of row*col in the array
mult[row-1][col-1] = row * col;
}
}
// Printing the table can be done with something
// like this
for (row = 0; row %26lt; 10; row++) {
for (col = 0; col %26lt; 10; col++) {
printf("%d ", mult[row][col]);
}
printf("\n");
}
}
// Good luck!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment