C++ Multiplication Table Generator

This is a discussion on C++ Multiplication Table Generator within the C++ Programming forums, part of the General Programming Boards category; Hi, I am currently taking C++ classes, and I have been given a simple (erm...) task of creating a C++ ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    14

    C++ Multiplication Table Generator

    Hi,

    I am currently taking C++ classes, and I have been given a simple (erm...) task of creating a C++ application that takes one input which is a number to one-decimal point e.g. 1.8, 1.9, 2.0, 2.1!

    A user enters a one decimal point number between 0 and 20, and the app uses a loop to create a table up to that number in the format (if a user enters 1.3 then) -:

    ____ 1.0 | 1.1 | 1.2 | 1.3

    1.0__1.0___1.1__ 1.2___1.3
    1.1__1.1___1.21_ 1.32__1.43
    1.2__1.2___1.32__1.44__1.56
    1.3__1.3___1.43__1.56__1.69

    (I had to use underscores to align the table because double spaes get removed in my post!)

    I need to hand this in, and i've been burning my brain for hours!!!

    I've currently got this going:

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    	double MAX = 20.00;
    
    	cout << "Please enter scale of the multiplication table..." << endl;
    	cin >> MAX;
    
    	for(double i = 0.00; i < MAX; i = i + 0.1)
    	{
    		cout << i << "\t";
    	};
    
    	return 0;
    }
    Thanks in advance.
    VD
    Last edited by Visual Develope; 05-15-2002 at 10:34 AM.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    take a look at the table you generated and ask yourself how did I get each of these values. Then look in your textbook/tutorial for the topic of multidimensional arrays. Briefly, multidimensional arrays can be used to create tables. Nested loops play a prominent role in creating and manipulating values in the multidimensional array. Each "cell" in the array is accessed using a two indexes, one representing a row and the other representing a column. Then note that if row or column index is 0 that these values in your table are treated differently thatn all the other values in your table.

  3. #3
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317

    Re: C++ Multiplication Table Generator

    Originally posted by Visual Develope
    (I had to use underscores to align the table because double spaes get removed in my post!)
    Since the code tag uses a monospaced font, I believe it will also deal with that kind of formatting.
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Re: Re: C++ Multiplication Table Generator

    Originally posted by Mario


    Since the code tag uses a monospaced font, I believe it will also deal with that kind of formatting.
    Code:
    That       is           so          True!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    Code:
    The only thing i dont like about code tags is if you go on and type lots and lots and lots and lots and lots of words, it will make the scroll bar apear at the bottom, making it hard for people with lower resolutions to read it,  SEE WHAT I MEAN?
    "There are three kinds of people in the world...
    Those that can count and those that can't."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiplication table
    By freddyvorhees in forum C++ Programming
    Replies: 6
    Last Post: 08-02-2008, 11:09 AM
  2. Automata Transition Table Generator?
    By audinue in forum C Programming
    Replies: 0
    Last Post: 06-25-2008, 04:30 AM
  3. Writing array, to file
    By zootreeves in forum C Programming
    Replies: 9
    Last Post: 09-08-2007, 05:06 PM
  4. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 09:56 AM
  5. multiplication table
    By SpEkTrE in forum C Programming
    Replies: 2
    Last Post: 12-09-2003, 03:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21