Saturday, 15 September 2012

c# - Multiplication Table Displaying Incorrectly -



c# - Multiplication Table Displaying Incorrectly -

i have write code create 10x10 multiplication table , display must this:

however, can't figure out how display code correctly. here code below. know i'm close, i'm not sure i'm doing wrong.

/* * programme displays multiplication table of product of every integer 1 through 10 * multiplied every integer 1 through 10. * */ using system; using system.collections.generic; using system.linq; using system.text; namespace displaymultiplicationtable { class programme { static void main(string[] args) { int value = 10; (int x = 1; x <= value; ++x) console.write("{0, 4}", x); console.writeline(); console.writeline("_________________________________________"); (int x = 1; x <= value; ++x) console.writeline("{0, 4}", x); (int row = 1; row <= value; ++row) { (int column = 1; column <= value; ++column) { console.write("{0, 4}", row * column); } console.writeline(); } console.readline(); } } }

int value = 10; // indent column headers console.write("{0, 4}", null); // write column headers (int x = 1; x <= value; ++x) console.write("{0, 4}", x); // write column header seperator console.writeline(); console.writeline("_____________________________________________"); // write table (int row = 1; row <= value; ++row) { // write row header console.write("{0, 4}", row); (int column = 1; column <= value; ++column) { // write row values console.write("{0, 4}", row * column); } // finish line console.writeline(); }

c# multiplication

No comments:

Post a Comment