# multiplication table

Page 1 of 1

## 2 Replies - 4736 Views - Last Post: 17 April 2008 - 01:29 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=49304&amp;s=e862793ccc385c8acc75248956be0b7b&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ariyawansa

• New D.I.C Head

Reputation: 0
• Posts: 1
• Joined: 16-April 08

# multiplication table

Posted 16 April 2008 - 09:57 PM

#include <stdio.h>

int main(){

int m, n;
int i, j;

printf("\nThis program generates an m x n multiplication table.");
printf("\nEnter number of rows (m): ");
scanf("%d", &m);
printf("Enter number of columns (n): ");
scanf("%d", &n);

for(i = 1; i <= m; i++){
for(j = 1; j <= n; j++){
printf("%4d", (i*j));
}
}
system("PAUSE");
return 0;
}

Is This A Good Question/Topic? 0

## Replies To: multiplication table

### #2 gabehabe

• GabehabeSwamp

Reputation: 1431
• Posts: 11,006
• Joined: 06-February 08

## Re: multiplication table

Posted 17 April 2008 - 04:24 AM

Not bad, there are only two things to point out:
• The system(); function is in <iostream>, which is a standard C++ library. Better practise in C would be to #include <conio.h> and replace system(); with getch();
• The other thing is that this program works, it's just that it all prints on the same line, correct? Try putting printf("\n"); JUST after your nested for loop, like so:
```for(i = 1; i <= m; i++)
{
for(j = 1; j <= n; j++)
printf("%4d", (i*j));

printf("\n");
}
```

Hope this helps

Oh, and welcome to </d.i.c>

### #3 محمداسد

• New D.I.C Head

Reputation: 0
• Posts: 4
• Joined: 17-April 08

## Re: multiplication table

Posted 17 April 2008 - 01:29 PM

gabehabe, on 17 Apr, 2008 - 04:24 AM, said:

Not bad, there are only two things to point out:
• The system(); function is in <iostream>, which is a standard C++ library. Better practise in C would be to #include <conio.h> and replace system(); with getch();
• The other thing is that this program works, it's just that it all prints on the same line, correct? Try putting printf("\n"); JUST after your nested for loop, like so:
```for(i = 1; i <= m; i++)
{
for(j = 1; j <= n; j++)
printf("%4d", (i*j));

printf("\n");
}
```

Hope this helps

Oh, and welcome to </d.i.c>

Great !