Looking for a proper out put

/*nested For loop that prints out a multiplication table for the integers
1 through 10. */
How do I get tabled results from my code
--------------------------------------------------------------------------

#include <iostream>
using namespace std;
int main( )
{
for (int n=1; n<=2; n++)
for (int m=1; m<=2; m++)
cout << (n*m);

system("pause");
return 0;
}//loop1.cpp
For these kinds of problems I like to use graph paper. Each square represents a character cell on the output terminal.

Draw what your output should look like. Then you can count to see how many cells are needed to hold each number (plus space between numbers).

To make your cout statements do the same thing, use the setw() manipulator.

Also, at the end of each row (represented by the outer loop), you will need to emit endl.

Hope this helps.
It hasn't really helped yet.
This is what I have but the results are still abit messy

#include <iostream>
//#include <iomanip>
using namespace std;
int main( )
{
for (int n=1; n<=10; n++)
{
cout << n << endl;
for (int m=1; m<=10; m++)

cout << m ;
//cout <<(n * m) << endl;
}


system("pause");
return 0;
}//loop1.cpp
Topic archived. No new replies allowed.