Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,109 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,707 people online right now. Registration is fast and FREE... Join Now!




Muitiplication Table In C++

 
Reply to this topicStart new topic

Muitiplication Table In C++, Write a Program to generates the multiplication table.The program is t

hamilton718
11 Oct, 2007 - 05:46 AM
Post #1

New D.I.C Head
*

Joined: 11 Oct, 2007
Posts: 1


My Contributions
Very Confused with this program please help thanks
User is offlineProfile CardPM
+Quote Post

Smarf
RE: Muitiplication Table In C++
11 Oct, 2007 - 05:49 AM
Post #2

D.I.C Head
**

Joined: 21 Sep, 2007
Posts: 80



Thanked: 2 times
My Contributions
A few things to help you out:

- Post your code, like the big grey letters say every time you create a post. People here won't do your homework for you, you need to make an effort.

- Be more specific about your problem. What exactly are you having trouble with? What is your output? What is your output supposed to look like?


User is offlineProfile CardPM
+Quote Post

adeoluwafemi
RE: Muitiplication Table In C++
11 Oct, 2007 - 01:25 PM
Post #3

New D.I.C Head
*

Joined: 11 Oct, 2007
Posts: 5


My Contributions
ok i have a problem. My professor doesnt teach well and the book we using is very extremely confusing. she told us to do a multiplication table that asks user for the amount of number the table should display.


suppose to look like this when he outputs


Enter amount of number for table: 3


1 2 3
2 4 6
3 6 9


Im not asking for someone to do the work for me cos i wont learn that way but can someone please show me how to make it output like this. I know how to do the for loop and the other loop. But its been giving me headache how to make it display like that and how to make it to be any number the user inputs. Please help
User is offlineProfile CardPM
+Quote Post

jjhaag
RE: Muitiplication Table In C++
11 Oct, 2007 - 01:30 PM
Post #4

me editor am smartastic
Group Icon

Joined: 18 Sep, 2007
Posts: 1,789



Thanked: 2 times
Dream Kudos: 775
Expert In: C,C++

My Contributions
please post the code you have, and we can try to point you in the right direction. the resolution to your problem is quite possibly going to depend on the rest of your code, so it's hard to give you any kind of an answer without seeing what you've done.

-jjh
User is offlineProfile CardPM
+Quote Post

adeoluwafemi
RE: Muitiplication Table In C++
11 Oct, 2007 - 01:31 PM
Post #5

New D.I.C Head
*

Joined: 11 Oct, 2007
Posts: 5


My Contributions
ok this is what i came up with so far.

CODE
#include <iostream.h>
#include <conio.h>
int main()

{
    int a,i;
    
    cout<<"Enter amount of table";
    cin>>a;
    
    for(i=1;i<=a;i++)
    cout<<a<<endl;
    
    return 0;
}

User is offlineProfile CardPM
+Quote Post

jjhaag
RE: Muitiplication Table In C++
11 Oct, 2007 - 01:53 PM
Post #6

me editor am smartastic
Group Icon

Joined: 18 Sep, 2007
Posts: 1,789



Thanked: 2 times
Dream Kudos: 775
Expert In: C,C++

My Contributions
well, this code will only give you a single line of the values 1...a. you should probably try a nested for loop, something like this:
CODE
for (i=1; i<=a; ++i) {
    for (j=1; j<=a; ++j) {
        //display stuff here
    }
}


and please post your code using code tags - take a look at the grey text on the background of the new post/reply text box.

hope that helps,

-jjh
User is offlineProfile CardPM
+Quote Post

adeoluwafemi
RE: Muitiplication Table In C++
11 Oct, 2007 - 06:00 PM
Post #7

New D.I.C Head
*

Joined: 11 Oct, 2007
Posts: 5


My Contributions
QUOTE(jjhaag @ 11 Oct, 2007 - 02:53 PM) *

well, this code will only give you a single line of the values 1...a. you should probably try a nested for loop, something like this:
CODE
for (i=1; i<=a; ++i) {
    for (j=1; j<=a; ++j) {
        //display stuff here
    }
}


and please post your code using code tags - take a look at the grey text on the background of the new post/reply text box.

hope that helps,

-jjh



How do i do that? using [code][/code]? and also where u put //display stuff here, wut do u mean by that? comments?


User is offlineProfile CardPM
+Quote Post

jjhaag
RE: Muitiplication Table In C++
11 Oct, 2007 - 06:57 PM
Post #8

me editor am smartastic
Group Icon

Joined: 18 Sep, 2007
Posts: 1,789



Thanked: 2 times
Dream Kudos: 775
Expert In: C,C++

My Contributions
yes, those are the code tags. you should enclose the source code you post in them so that the displayed code is easy to read, as well as to copy and paste.

the two forward slashes indicate the start of a single-line comment, and they were to indicate to you that location is where you should put the display statements.

-jjh
User is offlineProfile CardPM
+Quote Post

XenoSophist
RE: Muitiplication Table In C++
12 Oct, 2007 - 09:04 AM
Post #9

New D.I.C Head
*

Joined: 2 Oct, 2007
Posts: 36


My Contributions
it seems that a 2D array would work well. If I understand the example enough, the prompt would ask the user to define rows and columns. For instance, if the user entered "9" when prompted, the output table would be 9 rows by 9 columns. The first row would start with 1 and add 1 for the next array element. The second row would start with 2 and add 2 for every column proceeding it etc.

Therefore, your first row would be:
1 2 3 4 5 6 7 8 9
The second row would be:
2 4 6 8 10 12 14 16 18
The third row would be:
3 6 9 12 15 18 21 24 27

This would give the idea of a 9x9 table.

I hope this helps you design your pseudo-code as that should be the first step.

This post has been edited by XenoSophist: 12 Oct, 2007 - 09:05 AM
User is offlineProfile CardPM
+Quote Post

sudhakoshti
RE: Muitiplication Table In C++
14 Oct, 2007 - 05:52 PM
Post #10

New D.I.C Head
*

Joined: 14 Oct, 2007
Posts: 1


My Contributions
QUOTE(adeoluwafemi @ 11 Oct, 2007 - 02:25 PM) *

ok i have a problem. My professor doesnt teach well and the book we using is very extremely confusing. she told us to do a multiplication table that asks user for the amount of number the table should display.


suppose to look like this when he outputs


Enter amount of number for table: 3


1 2 3
2 4 6
3 6 9


Im not asking for someone to do the work for me cos i wont learn that way but can someone please show me how to make it output like this. I know how to do the for loop and the other loop. But its been giving me headache how to make it display like that and how to make it to be any number the user inputs. Please help



here is a solution to your problem.


#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],i,j;
clrscr();
for(i=1;i<=3;i++)
{
for(j=i;j<=(3*i);j=j+i)
{
printf("%d",j);
}
}
getch();
}
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:31PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month