OK.So i need to bild this table and so I did.But what I cant understand is why it works fine till I hit number 18.then sudenly like half of 1st number-s (array[x]) are missing. can someone please tell me whats the trick.Thank you.

#include <iostream>

using namespace std;

int main()
      int size=0;
      cout << "Enter a size? : ";
      cin >> size;

      int *Array = new int[size];

      for(int i = 0;i<size;i++){



        for(int x = 0;x < size;x++){

            for(int y = 0;y<size;y++) {

                cout << Array[x]<<" x "<<Array[y]<<" = "<<Array[x]*Array[y]<<endl;




First off, don't forget to delete all memory allocated using new.

Second, if your intent is to print out the table, then you don't actually need the array at all, as Array[x] will always equal x + 1 anyway.

Third, as things are now, you are printing a single entry on each line; it would make a lot more sense, and take up much less space, to write it as a table or matrix.

Fourth, given that you are displaying the results of multiplying by successive integers, you can save a little time at the price of a trivial amount of memory, by using an accumulator variable and adding by x each time:

    for (int n = 1; n <= size; n++) {
        cout << setw(4) << n << ' ';

    cout << endl;

    for (int dash = 0; dash < size; dash++) {
        cout << "-----";

    cout << endl;

    int acc = 0;

    for (int y = 1; y <= size; y++) {
        for (int x = 1; x <= size; x++) {
           acc += y;
           cout << acc;
        acc = 0;
        cout << endl;

Finally, if you wanted to actually have a table in memory of the results, as a two-dmensional array, You would want to declare the table as something like:

    int** matrix = int[size];

    for (int i = 0; i < size; i++) {
        matrix[i] = new int[size];

You could then print out the table fairly easily.

Edited 3 Years Ago by Schol-R-LEA

This article has been dead for over six months. Start a new discussion instead.