0

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!

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by dexter1984
0

Wow, thanks for the quick reply.
I didn't notice that " " because I put it in very early.
Aaaaa now I feel stupid =\

Thanks anyway =]

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.