Help with table.

Hello, I cannot seem to get my 2 to 12 times table project to align from the 10s down. Tried adding an if else to change setw by one this does not help so returned it to 5. Any help would be very much appreciated. Thanks in advance; code below.

// EX3_Q4.cpp : Defines the entry point for the console application.


#include "stdafx.h"
#include <iostream>
# include <iomanip>
using namespace std;
// Write a program that output the times tables from 2 to 12 columes and rows.

int main()
{
cout<<endl<<"This program prints out the multiplication tables from 2 to to 12"<<endl;
cout<<endl;
int i(0);
int count(1);

for(int i = 1; i<=12;i++)
{

cout<<i<<setw(5); //outputs top number title row
}
cout<<"\n";
for(int i = 2; i<=12;i++)
{
cout<<"______"; //outputs underline fro title row
}
cout<<endl;

for(int y=2;y<=12;y++) // loop for tables
{

count++; // increment for each table
cout<<" "<<endl;


for(int x =1; x<=12 ;x++)
{
if(count <=9)
cout<<x*count<<setw(5); // prints out each table
else

cout<<x*count<<setw(5); // prints out each table

}

}


cout<<endl;
return 0;
}
Try changing this:
cout<<i<<setw(5);

to this:
cout<<setw(5)<<i;
etc.
Topic archived. No new replies allowed.