English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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<=25;count1++)
{
for(count2=1;count2<=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.

2007-02-23 17:43:15 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

yes Alan ,you are right but did you try it . Because
when you run the program, the first line is 2-50 which must be 1-25.
so can you make the first line 1 -25 and the last line 25 -650.

2007-02-23 18:12:22 · update #1

BigRez , it still do not show the 1-25 on the first line.Ok , the program must show the multiplication table in the 1st whole screen (with 1-25 in the first line and 25-625 at the last).

2007-02-23 18:53:20 · update #2

4 answers

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<=25; count1++)
printf("%3d ",count1);
printf("\n .");
for(count1=1;count1<=25; count1++)
printf("--- ",count1);
printf("\n");

for(count1=1; count1<=25; count1++) {
printf("%2d| ",count1);
for(count2=1; count2<=25; count2++) {
value=count1*count2;
printf("%3d ",value);
}
printf("\n");
}

2007-02-23 18:31:17 · answer #1 · answered by BigRez 6 · 0 0

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.

2007-02-23 17:57:32 · answer #2 · answered by Alan 6 · 0 0

2. and 4. odd values - only if both the x and y are odd, so for(x=1; x<=9 ; x+=2 ) { // jump two units ... for(y=1; y<=9; y+=2 ) { ... //print or total as the case may be. } } 3., 5., even values - this time, you need to loop thru all the 81 values, and insert the following check in the inner most loop ( that at least one of x or y is even, so that the product is even ) : if( x%2 == 0 || y%2 == 0 ) { //x%2 is 0 if x is even. % is the modulo operator //do the compute here. total = total + x* y; } Diagonal case : This is where you have x=y, so you only loop once. for(x=1; x<=9; x++){ ... printf(... , x*x ) ; //etc...

2016-03-29 09:41:10 · answer #3 · answered by Anonymous · 0 0

i hate ur mom

2007-02-23 17:50:12 · answer #4 · answered by Anonymous · 0 1

fedest.com, questions and answers