So, to the point.
it is a console program.
The program has to take 2 numbers, one representing the starting number the other the ending number, and take those two numbers and output a multiplication table.
The area I'm lost on is the sum of the table. It is suppose to take all the numbers on the table and add them up, but I cant get it to do it. Every thin I've tried breaks the program.
The table Format is off, bit I may be able to figure that out on my own.
For the purposes of consistency, Im useing 2 for the first number and 5 for the second.
The output should look like this
X 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
Rows printed = 4
Columns printed = 4
Sum: 196
But Im getting
X 1 2 3 4 5
1 1 2 3 4 5
2 2 4 6 8 10
Rows printed: 2
Columns printed: 5
Sum of the Table: 9
#include <iostream>
using namespace std;
int main()
{
int low = 0;
int high = 0;
int rows = 0;
int columns = 0;
int accumOne = 0;
int accumTwo = 0;
cout << "Enter first number: ";
cin >> rows;
cout << "Enter second numnber: ";
cin >> columns;
cout << endl;
cout << "THE MULTIPLICATION TABLE";
cout << endl;
for (high = 1; high <= columns; high++)
{
cout << "\t" << high;
}
cout << endl;
accumOne = accumOne + high;
for (low = 1; low <= rows; low++)
{
cout << low;
accumTwo = accumTwo + low;
for (high = 1; high <= columns; high++)
{
cout << "\t" << low * high;
}
cout << endl;
}
cout << "Rows printed: " << rows << endl;
cout << "Columns printed: " << columns << endl;
cout << "Sum of table: " << accumOne + accumTwo << endl;
return 0;
}
This post has been edited by NewbieDan: 22 July 2009 - 10:11 AM

New Topic/Question
Reply




MultiQuote




|