Multiplication Table using For Loops

Need to remove an unwanted column in the multiplication table

Page 1 of 1

3 Replies - 9078 Views - Last Post: 27 April 2008 - 05:43 PM Rate Topic: -----

#1 squirrel00  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-April 08

Multiplication Table using For Loops

Posted 08 April 2008 - 04:31 PM

Hey everyone,
Im trying to make a multiplication table that uses for loops, but not the console application. I have the table itself with all its values but theres a extra column that comes up at the end that I dont want.
For example it looks like this:
1 2 3 1
2 4 6 2
3 6 9 3
Does anyone know how to remove that last comlumn?
This is the code I used:

int q,i,j;

			for (i = 1; i <= 15; i++)
			{
				for (j = 1; j <= 15; j++)
									   
				{
					q = (i * j);
					memo.AppendText(q.ToString() + "\t");
					
				}

				memo.AppendText(i.ToString() + "\n\n\n");
			}



The memo is just the name of the richtext box.
Thanks in advance, any help will be greatly appreciated.
Aaron

Is This A Good Question/Topic? 0
  • +

Replies To: Multiplication Table using For Loops

#2 priceaprice  Icon User is offline

  • New D.I.C Head

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

Re: Multiplication Table using For Loops

Posted 24 April 2008 - 12:39 AM

Hiya, I have that problem too and am stuck. Did you fix it in the end?

View Postsquirrel00, on 8 Apr, 2008 - 04:31 PM, said:

Hey everyone,
Im trying to make a multiplication table that uses for loops, but not the console application. I have the table itself with all its values but theres a extra column that comes up at the end that I dont want.
For example it looks like this:
1 2 3 1
2 4 6 2
3 6 9 3
Does anyone know how to remove that last comlumn?
This is the code I used:

int q,i,j;

			for (i = 1; i <= 15; i++)
			{
				for (j = 1; j <= 15; j++)
									   
				{
					q = (i * j);
					memo.AppendText(q.ToString() + "\t");
					
				}

				memo.AppendText(i.ToString() + "\n\n\n");
			}



The memo is just the name of the richtext box.
Thanks in advance, any help will be greatly appreciated.
Aaron

Was This Post Helpful? 0
  • +
  • -

#3 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: Multiplication Table using For Loops

Posted 24 April 2008 - 03:33 PM

Isn't the problem here -> memo.AppendText(i.ToString() + "\n\n\n");

Try changing that to this: memo.AppendText("\n\n\n");

Basically, what you're doing is adding q to the end of the line, where you don't need to be.

Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#4 priceaprice  Icon User is offline

  • New D.I.C Head

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

Re: Multiplication Table using For Loops

Posted 27 April 2008 - 05:43 PM

Thanks, that worked a treat!

View Postgabehabe, on 24 Apr, 2008 - 03:33 PM, said:

Isn't the problem here -> memo.AppendText(i.ToString() + "\n\n\n");

Try changing that to this: memo.AppendText("\n\n\n");

Basically, what you're doing is adding q to the end of the line, where you don't need to be.

Hope this helps :)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1