# multiplication table

Page 1 of 1

## 3 Replies - 4267 Views - Last Post: 25 April 2008 - 12:28 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=49942&amp;s=0aa1f8e11961fc4b95346f548451f330&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 priceaprice

Reputation: 0
• Posts: 6
• Joined: 24-April 08

# multiplication table

Posted 24 April 2008 - 12:17 AM

Hi all. I should joined in some time ago but I had a few other very big assignments and now I`ve returned to this to try and get past this.

I need to do a multiplication table: 15*15 using 2 for loops, one nested inside the other. The problem is I am a bit lost and confused.

for (int  accross = 1; accross < 13; accross = accross + 1)
{
if ((accross % 6) == 0)

{ memo.AppendText("*"); }
memo.AppendText(accross.ToString() + "\n");

for (int down = 1; down < 13; down = down + 1)
{
if ((down % 6) == 0)

{ memo.AppendText("*"); }
memo.AppendText((accross * down).ToString() +"\t");

Any help and guidance appreciated.

Thanks

Is This A Good Question/Topic? 0

## Replies To: multiplication table

### #2 rgfirefly24

• D.I.C Lover

Reputation: 448
• Posts: 2,184
• Joined: 07-April 08

## Re: multiplication table

Posted 25 April 2008 - 12:20 PM

also what errors are you getting??

i cant test it right as i only have access to VS 6.0 but try this:
for (int accross = 1; accross < 13; accross++)
for (int down = 1; down < 13; down++)
{
if ((accross % 6) == 0)

{ memo.AppendText("*"); }
memo.AppendText(accross.ToString() + "\n");

if ((down % 6) == 0)

{ memo.AppendText("*"); }
memo.AppendText((accross * down).ToString() +"\t");
}

when i get to my dev box i'll check this code out more.

This post has been edited by rgfirefly24: 25 April 2008 - 12:21 PM

### #3 Martyr2

• Programming Theoretician

Reputation: 5187
• Posts: 13,917
• Joined: 18-April 07

## Re: multiplication table

Posted 25 April 2008 - 12:22 PM

Well you are certainly on the right track. Just a few minor adjustments like the range of your rows and columns and and you will have it. I am not sure why you are adding the asterisk in there, but you are doing it right if you want the asterisk to appear for every value that is a multiple of 6.

// Example for you
private void button1_Click(object sender, EventArgs e)
{
// For each row from 1 to 15
for (int down = 1; down <= 15; down++)
{
// Loop across from 1 to 15
for (int across = 1; across <= 15; across++)
{
// Appending the multiplication of the row and the column (adding a space for formatting)
memo.AppendText((across * down).ToString() + " ");
}

// At the end of each row, add a carriage return line feed
memo.AppendText("\r\n");
}
}

The above example will then print the multiplication chart in the memo textbox. Enjoy!

"At DIC we be multiplication table mastering code ninjas... DIC = Me * 80000 members"

### #4 Jayman

• Student of Life

Reputation: 421
• Posts: 9,532
• Joined: 26-December 05

## Re: multiplication table

Posted 25 April 2008 - 12:28 PM

Topic renamed to be more descriptive.