# multiplication table

• 12-09-2003
SpEkTrE
multiplication table
I am writting a program that displays a multiplication table....but my output is a constant 144 144 144 etc....

I cant find the error in my program.

Code:

```#include <stdio.h> #include<stdlib.h> int multab(int, int); int main() {         int a,b;         int table[12][12];         FILE * outfile;         outfile = fopen ("Michael Kuck's Project 4.txt", "w");         printf("Michael Kuck's Project 4 \n\n");         fprintf(outfile, "Michael Kuck's Project 4 \n\n");                 printf("                                        Multiplication Table \n\n");                 fprintf(outfile, "                                        Multiplication Table \n\n");         for (a =1; a=12; a++)         {                 for (b=1; b=12;b++)                 {                         table [a][b] = multab(a,b);                // function call (multiplication)                         printf("%5d", table [a][b]);                         fprintf(outfile, "%5d", table [a][b]);                 }                 printf("\n\n");                 fprintf(outfile, "\n\n");         }         printf("End of Project 4 \n\n");         fprintf(outfile, "End of Project 4\n\n");         fclose(outfile);         return 0; } //end of function main int multab(int a, int b) // recursive definition for multiplication function {         int result;         if (b==1)                 result = a;         else                 result = a + multab(a,b -1);         return(result); } //end of function multab```
thanks
• 12-09-2003
swoopy
Code:

```>        for (a =1; a=12; a++) >        { >                for (b=1; b=12;b++)```
You are setting a and b equal to 12 as your for-loop condition. Instead use:
Code:

```        for (a =1; a<12; a++)         {                 for (b=1; b<12;b++)```
• 12-09-2003
SpEkTrE
duh! thanks swoopy!!