Monday, May 24, 2010

Multiplication table in C?

how can i put a multiplication table with 25 x 25 as the last numbers.


my code right now is :








main()


{


int count1,count2,value;





for(count1=1;count1%26lt;=25;count1++)


{


for(count2=1;count2%26lt;=25;count2++)


{


value=count1*count2;


printf("%3d",value);


}


printf("\n");


}





getch();


clrscr();


}





i need to have 1 -25 on the top appear !. !. with your help.

Multiplication table in C?
The table is correct, but I would suggest making your printf as "3d " so that the three-digit numbers have a space.





To get the 1-25 listed on top, you must have an initial for loop to do that... Oh, and then to make it nice and pretty...





printf(" ");


for(count1=1;count1%26lt;=25; count1++)


printf("%3d ",count1);


printf("\n .");


for(count1=1;count1%26lt;=25; count1++)


printf("--- ",count1);


printf("\n");





for(count1=1; count1%26lt;=25; count1++) {


printf("%2d| ",count1);


for(count2=1; count2%26lt;=25; count2++) {


value=count1*count2;


printf("%3d ",value);


}


printf("\n");


}
Reply:I assume those FOR statments end with count1++ and count2++





So, what's wrong?


What are you getting, that you don't want?


- - - - - - - -


Have you checked the obvious? That is- do you have a 25-line screen?





If you do, then the 1st line is simply scrolling off the top.


Try a 10x10 array, see what you get.
Reply:i hate ur mom


No comments:

Post a Comment