need help with 5x5 multiplication table

Page 1 of 1

3 Replies - 378 Views - Last Post: 24 January 2019 - 06:37 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=414596&amp;s=09e7873675c879ea7fe82464b8c250d2&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 eeeeela

Reputation: 0
• Posts: 2
• Joined: 24-January 19

need help with 5x5 multiplication table

Posted 24 January 2019 - 09:14 AM

so we have this activity given by our professor about making a 5x5 multiplication table, the output should be like this:
0 1 2 3 4
1 1 2 3 4
2 2 4 6 8
3 3 6 9 12
4 4 8 12 16

and so i typed in the code:
#include <iostream>

using namespace std;

int main(){

int A, B;
int C[10] = {1,2,3,4,5,6,7,8,9,10};
int D;

cout << "enter number for table [1-10 only]:";
cin >> input;

for(A=0; A<=D; A++)
{
for(B=1; B<=D; B++)
{
cout << (A*B)/>/>;
}
cout<<endl<<endl;
}

system("pause");
return 0;
}

---------
and the OUTPUT is:
0000
1234
2468
36912
481216

and yes, i know i got the variable C in there but i'm confused as to where i'm supposed to place it in the code. My apologies, programming is not one of my strengths.

This post has been edited by modi123_1: 24 January 2019 - 09:29 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.

Is This A Good Question/Topic? 0

Replies To: need help with 5x5 multiplication table

#2 modi123_1

• Suitor #2

Reputation: 14859
• Posts: 59,283
• Joined: 12-June 08

Re: need help with 5x5 multiplication table

Posted 24 January 2019 - 10:43 AM

Big issue, just eyeballing it, is 'input' is never declared.

#3 dr3am1nc0d3

Reputation: 0
• Posts: 12
• Joined: 01-December 18

Re: need help with 5x5 multiplication table

Posted 24 January 2019 - 11:55 AM

I noticed that input is never declared and the variable D is never instantiated to anything other than 0. You declare D but you never set it.

Go through the code step by step, what is it doing in the inner loop?

#4 eeeeela

Reputation: 0
• Posts: 2
• Joined: 24-January 19

Re: need help with 5x5 multiplication table

Posted 24 January 2019 - 06:37 PM

oh my mistake i must've put input in there for some reason. this is what happens when i lack caffeine while working lol