0% found this document useful (0 votes)
22 views

Multiplication Program

This C program prints out a multiplication table from 1 to 10. It uses nested for loops to print the column headers, a dashed line, and then iterates through each row to calculate and print the results of multiplying the row number by each column number from 0 to 10.

Uploaded by

Rigobert Ngeleja
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Multiplication Program

This C program prints out a multiplication table from 1 to 10. It uses nested for loops to print the column headers, a dashed line, and then iterates through each row to calculate and print the results of multiplying the row number by each column number from 0 to 10.

Uploaded by

Rigobert Ngeleja
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

void printTable() { // pre-print column headers printf(" "); int c; for (c = 0; c <= 10; ++c) { printf("%4d", c); } printf("\n");

printf(" "); for (c = 0; c <= 10; ++c) { printf(" -"); } printf("\n"); // calculations int r; for (r = 0; r <= 10; ++r) { // row headers printf("%2d|", r); // calculation for the current row for (c = 0; c <= 10; ++c) { printf("%4d", (r * c)); } printf("\n"); } } Read more: http://wiki.answers.com/Q/Writ_a_c_program_to_display_the_multiplication_tables_from_1_to_1 0#ixzz1xmpTBgOg

{ int number1; int number2; int result;

for (number1 = 1 ; number1 <= 12 ; number1++) { for (number2 = 1 ; number2 <= 12 ; number2++) { result = number1 * number2; printf ("%4d ",result); } printf("\n"); } }

You might also like