Hi,
I'm a student new to C++, just started learning it for 3 weeks. I just encountered a problem in making a multiplication table as an assignment.
Tried alot of methods but still can't figure out what's wrong.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int input, num1, num2;
cout << "This is a multiplication table program.\n" <<
"Please enter a number and the result will be shown.\n\n";
cin >> input;
cout << "\n\n";
for ( int num3 = 0; num3 <= input; num3++ )
cout << setw (6) << right << num3;
cout << "\n\n" ;
for ( num1 = 1; num1 <= input; num1++ )
{
cout << setw (6) << right << num1;
for ( num2 = 1; num2 <= input; num2++ )
cout << setw (6) << right <<
num2 * num1 << " ";
cout << "\n\n" ;
}
system("pause");
return 0;
}
What happens is that the first line shown is totally out of place.
Thanks for looking.
P.S. I had alot of help from this website by reading up. Thanks!