Write a console program that will output "multiplication tables" for the digits 1-10 multiplied by 1-10. Your output will look like this:
1 2 3 4 ...
2 4 6 8 ....
....
7 14 21 28 ....
etc.
This is best done with a loop inside a loop.
Include comments telling what each line does and who wrote the program and its purpose.
Since this is a console program I only need the .cs file. Be sure to include your name in the filename. I don't want 20 programs named mult1.cs.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace multi
{
class Program
{
static void Main(string[] args)
{
//prints program purpose and who made
Console.WriteLine("Program prints multiplication tables for the digits 1-10 multiplied by 1-10.");
Console.WriteLine("Made by");
Console.WriteLine(" ");
Console.Write(" ");
//prints table header from 1 to 10
for (int i0 = 1; i0 <= 10; i0++)
{
Console.Write("{0, -3}", i0);
}
Console.WriteLine();
// goes from 1 to 10
for (int i = 1; i <= 10; i++)
{
// prints rows headers
Console.Write("{0,-3}", i);
// goes from 1 to 10 for multiply
for (int j = 1; j <= 10; j++)
{
//ouputs result
Console.Write("{0, -3}", i*j);
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Comments
Leave a comment