Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9101339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:06:17+00:00 2026-06-17T01:06:17+00:00

I am a newbie in C++ programming and trying to learn the language from

  • 0

I am a newbie in C++ programming and trying to learn the language from reading an Ebook called Jumping into C++ by Alex Allain, and I have currently finished the dynamic memory allocation chapter and I must say that I find pointers difficult to understand.

At the end of the chapter is a series of practice problem I can try out, I have completed the first problem (took me a while to get my code working) which is to write a function that builds the multiplication table of arbitrary dimensions (you have to use pointers for the problem), but I am not satisfied with my solution if it’s correct and if I am using the pointers the right way, I want someone who has experience to point out the flaws, if there are, below is my own solution to the problem:

// pointerName.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include <iostream>
#include <string>

void multTable(int size){

    int ** x, result;
    x = new int*[size]; //  lets declare a pointer that will point to another pointer :).
    result = 0; 

    for(int h = 0; h < size; h++){ // lets store the address of an array of integers.
            x[h] = new int [size];      
    }
    std::cout << std::endl << "*********************************" << std::endl; // lets seperate. 
    for(int i=0; i < size+1; i++){ // lets use the pointer like a two-dimensional array.
        for(int j=0; j < size+1; j++){
            result = i*j; // lets multiply the variables initialized from the for loop.
            **x = result; // lets inialize the table.
            std::cout << **x << "\t"; // dereference it and print out the whole table.
        }
        std::cout  << std::endl;
    }
    /************* DEALLOCATE THE MEMORY SPACE ************/
    for(int index = 0; index < size; index++){
        delete [] x[index]; // free each row first.  
    }
    delete [] x; // free the pointer itself.
}

int main(int argc, char* argv[]){

    int num;
    std::cout << "Please Enter a valid number: ";
    std::cin >> num; // Lets prompt the user for a number.
    multTable(num);

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:06:18+00:00Added an answer on June 17, 2026 at 1:06 am

    What billz said and also **x must change to x[i][j]. Since you seem new it would be good practice to print the multiplication table as a seperate block (outside the two for loops).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to retrieve data from an Xml. I'm a newbie into programming so
I'm newbie in C++ programming. I'm trying to see the benefits from moving all
I'm a newbie to scala. I'm trying an example from the book Programming Scala.
I am newbie to iphone programming and trying to learn iphone programming.I need experts
Hi I am newbie in programming and I am trying to learn and make
I'm a newbie in iPhone Programming. I'm trying to send a message from one
I am a Java newbie trying to learn network programming and concurrency, and I
I'm a newbie into Android programming... Here's what I'm trying to do for a
I am newbie C# developer. When I just have started to learn programming thins
I am newbie to programming and I am trying to pass an array into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.