i have a question is there any way that i can add up all the value in a multiplication table i create or parscal triangle i created? if yes i need to find out how to add up all values in a multiplication table. i can't figure out the logic behind how, its frustrating.

the code will be like this:

#include <iostream>
using namespace std;

int main()
{
int i, j, total;
for (int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
cout << i*j;
total = i + j;
cout << total;
}
cout << endl;
}
return 0;
}

i know the above code doesn't work but i dont get it. why????????

Recommended Answers

All 4 Replies

First of all, please learn to format your code.

Are you trying to add all the i*j values together? If so, all you did is add the very last i and j values based on the loops. That's going to be 9+9 = 18. You need to add i*j to the running total. Something like total = total + (i * j) or thereabouts.

That code won't help you with Pascal's Triangle.

The computer is too stupid to help you do something. First figure out how to do it yourself, preferably with pencil and paper. Once you can do that, telling the computer how to do it is relatively easy.

> is there any way that i can add up all the values in a multiplication table?
you can do this in your mind

1*N + 2*N + 3*N + .... + (N-1)*N + N*N == 
          (1+2+3+...+(N-1)+N) * N == 
          ( ( N * (N+1) ) / 2 ) * N

i will try... thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.