how do i make a multiplication table with # of rows/columns depending on the user's input?

so far i only have the user input codes done but im so lost. i tried to watch youtube videos but none of them is right for what i am doing.

so basically i have to ask how many rows they would like and the output should be a multiplication table up to that number. i have no idea how to do this. i got the rows and columns done already but idk how i should put the actual numbers.... idk if this makes sense.

Attachment image

2 Answers

Relevance
  • 6 days ago
    Favorite Answer

    What language are you programming in?

    You will be using nested for loops to create your table.

    Basically, your pseudocode for the table would be:

    read n

    for row = 0 to n:

       for column = 0 to n:

          if row=0:

             if column=0: print "x"+tab

             else: print column+tab

          else:

             if column=0: print row+tab

             else: print row*column + tab

       end for column

       print newline

    end for row

  • EddieJ
    Lv 7
    6 days ago

    int main () {

    int integer = 0;

    int even = 0;

    int odd = 0;

    const int SENTINEL = -999;

    cout << "Enter an integer ending with -999: " << endl;

    while (true) {

     cin >> integer;

     if (integer == SENTINEL) break;

     if (integer % 2 == 0) even += integer;

     else odd += integer;

    }

    cout << "The sum of your even integers is: " << even << endl;

    cout << "The sum of your odd integers is: " << odd << endl;

    }

Still have questions? Get your answers by asking now.