Create the multiplication tables for 0 through the 10 times table.
The Method
Have a two-dimensional array called table
Fill the table with the products
Print the multiplication table
The Program
/* File: times.c
Author: Sue Bogar
Date Written: 2/24/98
Section: 101
SSN: 123-45-6789
EMail: bogar@cs.umbc.edu
Description: Illustrate two-dimensional arrays
by storing times tables for 0 through
10 in an array and then printing them
out.
*/
#include
#define SIZE 11
int main ( )
{
int i, j, table[SIZE][SIZE];
/* Fill table with the products of
the indices */
for (i = 0; i < SIZE; i++)
{
for (j = 0; j < SIZE; j++)
{
table[i][j] = i * j;
}
}
/* Print the table */
for (i = 0; i < SIZE; i++)
{
for (j = 0; j < SIZE; j++)
{
printf("%4d", table[i][j]);
}
printf ("\n");
}
return 0;
}