Please, help.... URGENT HOMEWORK QUESTION - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.


rharvisonrharvison Posts: 1Member
Hi, all. I am very new to C++ and totally stuck on a FOR loop. We are asked to input a number and generate a multiplication table using the input value. Number should be in the range of 1-12 [using a post-test loop to check for valid input.] Generate a Multiplication Table using a for statement, print the table showing the multiplier [the input value], the multiplicand [1- up to and including the end value of 15], and the product of each multiplication.

Output: Multiplier Multiplicand Product
6 1 6
6 2 12
6 3 18
etc. till 15

My code:
using namespace std;

int main(void)

int choice, //output choice
val_1, //first number [multiplier]
x, //multiplicand
result; //x * val_1

char name[21]; //name

ofstream outfile; //to write to an output file

//*****INPUT SECTION*****

system ("cls");
cout << "Enter name: ";
cin.getline(name, 21);
cout << "Enter number between 1 through 12: ";
cin >> val_1;


for ( int x = 1; x<=15; x++ )
{result = x * val_1;}


system ("cls");
cout << "Output Choice: 1 (Screen) 2 (File), choose 1 or 2: ";
cin >> choice;
system ("cls");
outfile << setiosflags(ios::showpoint|ios::fixed)<< setprecision(2);
outfile << "Name: " << name << endl << endl << endl << endl;
outfile << setw(45) << "Multiplication Table" << endl;
outfile << setw(45) << "====================" << endl << endl;
outfile << setw(20) << "Multiplier" << setw(20) << "Multiplicand" << setw(20)<<"Product" << endl;
outfile << setw(20) << val_1 << setw(20) << x << setw(20) << result << endl;
return 0;

Thank you for any help you can give. This homework is due tomorrow [Friday, April 22] by 7:00 p.m.

Sign In or Register to comment.