Generate a multiplication table
#include <stdio.h>
int main()
{
int table_size = 12;
int row = 0;
int col = 0;
for(col=0 ; col<=table_size ; col++){
printf(" %4d", col);
}
printf("\n");
for(col=0 ; col<=table_size ; col++){
printf("_____");
}
for(row = 0 ; row<=table_size ; row++){
printf("\n");
for(col = 0 ; col<=table_size ; col++) {
if(row == 0) {
if(col == 0){
printf(" ");
}else{
printf("|%4d", col);
}
}else{
if(col == 0){
printf("%4d", row);
}else{
printf("|%4d", row*col);
}
}
}
}
printf("\n");
}
Related examples in the same category