Multiplication Table Code Modification

Need to modify my multiplication table program from Do While to While.

Page 1 of 1

1 Replies - 2157 Views - Last Post: 21 April 2009 - 02:11 PM Rate Topic: -----

#1 zipperson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-March 09

Multiplication Table Code Modification

Posted 21 April 2009 - 01:32 PM

I need to modify this multiplication table program from the current Do While into a While and am not sure how to go about making it work.

Heres' the code::::::

 #include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{
	//declare variable
	char anotherTable = ' ';
	int multiplicand  = 0;
	int product	   = 0;

	do
	{
		//get the multiplicand
		cout << "Enter the multiplicand: ";
		cin  >> multiplicand;

		//display the multiplicand table 
		for (int multiplier = 1; multiplier < 10; multiplier += 1)
		{
			product = multiplicand * multiplier;
			cout << multiplicand << " * " << multiplier
				<< " = " << product << endl;
		}   //end for

		cout << endl;
		cout << "Display another multiplication table? (Y/N) ";
		cin >> anotherTable;
	} while (toupper (anotherTable) == 'Y');

	return 0;
}   //end of main function 


Is This A Good Question/Topic? 0
  • +

Replies To: Multiplication Table Code Modification

#2 BlakeJustBlake  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 26
  • View blog
  • Posts: 441
  • Joined: 15-February 09

Re: Multiplication Table Code Modification

Posted 21 April 2009 - 02:11 PM

Delete the do and the semicolon after the while statement. Move the while statement to where the do statement used to be. Done.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1