# Thread: A wee bit of help needed

1. ## A wee bit of help needed

I need to create an application that will display the multiplication table for a number entered. The application should ask the user to enter a number, check if number is between 2 and 12 (inclusive). If number entered is not in the range, should display error message. Otherwise display the multiplication table.

i have to use logical operators to check for valid number and the for loop for making the table.

2. Post problems with you have with the homework.. not just your homework.

3. If you want help your probably going to have to post a valid atempt (unless you want to email me privately with your credit card number, in which case I'd be more than happy to do your homework ).

You could use a for loop.

5. .

6. Jesus...
Code:
```int i;
int table;

cout << "What times table do you want: ";
cin >> table;

for (i = 1; i <= 12; i++)
cout << i << " times " << table << " = " << (i * table) << ".\n";```

7. ## Thankx, Sam

Ahhh, now i see where i was going wrong. I just started C++ a month ago, and have just recently "gotten" it.
I have been using this site frequently to use the tutorials, and thought the message board would be helpful.
thank you again

8. Jeez dude, this is lame. I just started on C++ 5 days ago and I could have dreamt up that code in a sec... I sure as hell hope for you you're gonna catch on a bit quicker.

9. Well I thought of being a bit more constructive here, so I went ahead and added some to what samGwilliam made:

Code:
```#include <iostream.h>

int main()
{
int i;
int num;
int goodToGo = 0;
char again;

while (!goodToGo)
{
cout<<"Please enter the table you want"<< endl << endl;
cin>>num;
cout<<endl;

if (num>=1 && num<=10)
{
goodToGo = 1;

cout<<"THE TABLE OF "<< num << ":" << endl;
cout<<"----------------"<< endl;

for (i=1; i<11; i++)
{
if (i<10)
{
cout<< i << "  times " << num << " = " << i*num << endl;
}
else
{
cout<< i << " times " << num << " = " << i*num << endl;
}
}

cout<< endl << "Would you like to see another table?" << endl;
cout<< "Press y/n: ";
cin>> again;

if (again == 'y')
{
goodToGo = 0;
// Best to clear screen here...
// See http://www.cprogramming.com/boardfaq.html#clear on how to do that
}
else
{
cout<< endl << "Have a nice day." << endl;
}
}
else
{
cout<<"The number you supplied is not in the range of 1 to 10"<<endl;
}
}
return 0;
}```
yur welcome.

10. Nice, but a tad overkill, no?

11. Yeah well, i'm an interaction designer. I aim to please

12. Cool.

Code:
```#include <iostream.h>
#include <stdlib.h>

class table
{
private:

int tableType;

public:

table (int type);
void display (int tableSize);
};

table::table (int type)
{
tableType = type;
}

void table::display (int tableSize)
{
int i;

cout << "The " << tableType << " times table:\n";

for (i = 1; i <= tableSize; i++)
cout << i << " times " << tableType << " = " << (i * tableType) << ".\n";
}

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

if (argc != 3)
{
cout << "Usage: " << argv [0] << " tableType tableSize.\n";
exit (1);
}

myTable = new table (atoi (argv [1]));
myTable->display (atoi (argv [2]));

cout << "Have a nice day!\n";

delete myTable;

return 0;
}```

13. Heh samG, can't compile it man.

14. char *argv []

15. Nice work. Thumbs up!