3 Replies - 3867 Views - Last Post: 09 March 2008 - 03:45 PM Rate Topic: -----

#1 spiritedwildfire  Icon User is offline

  • New D.I.C Head

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

How do I eliminate duplicates in multiplication table output?

Post icon  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  Icon User is offline

  • member icon

Reputation: 307
  • View blog
  • 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;
Was This Post Helpful? 0
  • +
  • -

#3 zmikeb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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;

}


:)
Was This Post Helpful? 0
  • +
  • -

#4 spiritedwildfire  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.) :)


View Postzmikeb, 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;

}


:)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1