Skip to content

Instantly share code, notes, and snippets.

Created October 19, 2011 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1299654 to your computer and use it in GitHub Desktop.
Save anonymous/1299654 to your computer and use it in GitHub Desktop.
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