3 Replies - 378 Views - Last Post: 24 January 2019 - 06:37 PM Rate Topic: -----

#1 eeeeela   User is offline

  • New D.I.C Head

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

:code:
---------
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   User is offline

  • Suitor #2
  • member icon



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

#3 dr3am1nc0d3   User is offline

  • New D.I.C Head

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

#4 eeeeela   User is offline

  • New D.I.C Head

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

Page 1 of 1