Skip to content

Instantly share code, notes, and snippets.

Created Oct 19, 2011
Embed
What would you like to do?
int main()
{ int n=1; // declare variable
cout << "0" << setw(5) << "1" << setw(5) << "2" << setw(5) << "3" << setw(5) << "4" << endl;
while (n<51)
{ if (n<10)
{ cout << n << setw(5) << n << setw(5) << setw(5) << 2*n << setw(5) << 3*n << setw(5) << 4*n << endl;
}
else
cout << n << setw(4) << n << setw(5) << setw(5) << 2*n << setw(5) << 3*n << setw(5) << 4*n << endl;
// if, else statement for better formatting
n++; // to increase our row value by 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment