How do I eliminate duplicates in multiplication table output?

Page 1 of 1

3 Replies - 3888 Views - Last Post: 09 March 2008 - 03:45 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=45628&amp;s=30c6027e2c8b1bccc5f74cb794d8bbed&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 spiritedwildfire

• New D.I.C Head

Reputation: 0
• Posts: 2
• Joined: 09-March 08

How do I eliminate duplicates in multiplication table output?

Posted 09 March 2008 - 09:52 AM

Just ran across this forum. I'm taking a beginners C++ course. Wrote the code below to display the output for multiplication tables from 1 - 10. My professor said I can change one mathematical expression from the 7 below, and it will eliminate doubles like 2 x 3, and 3 x 2 from happening. If anyone had any help in what I should change I would greatly appreciate it!

Thanks!

```

#include <iostream.h>

int main () {

for (int series = 1; series <=10; series ++) {

for (int multiplier =1; multiplier <=10; multiplier++)
cout << series * multiplier <<endl;

return 0;

}

```

Is This A Good Question/Topic? 0

Replies To: How do I eliminate duplicates in multiplication table output?

#2 GWatt

Reputation: 307
• Posts: 3,105
• Joined: 01-December 05

Re: How do I eliminate duplicates in multiplication table output?

Posted 09 March 2008 - 10:03 AM

in your second for loop you can say multiplier = series;

#3 zmikeb

• New D.I.C Head

Reputation: 0
• Posts: 33
• Joined: 01-March 08

Re: How do I eliminate duplicates in multiplication table output?

Posted 09 March 2008 - 02:32 PM

```#include <iostream>
using namespace std;

int main ()
{

for (int series = 1; series <= 10; series++ )
{
for (int multiplier = series; multiplier <= 10; multiplier++)
{
cout << series * multiplier <<endl;
}

}
return 0;

}
```

#4 spiritedwildfire

• New D.I.C Head

Reputation: 0
• Posts: 2
• Joined: 09-March 08

Re: How do I eliminate duplicates in multiplication table output?

Posted 09 March 2008 - 03:45 PM

Thanks! I'm going to test it, and I'll let you know what happens. (Although logically it seems right.)

zmikeb, on 9 Mar, 2008 - 02:32 PM, said:

```#include <iostream>
using namespace std;

int main ()
{

for (int series = 1; series <= 10; series++ )
{
for (int multiplier = series; multiplier <= 10; multiplier++)
{
cout << series * multiplier <<endl;
}

}
return 0;

}
```