Answer to Question #292685 in C# for Dave

Question #292685

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.

1
Expert's answer
2022-02-01T06:23:05-0500
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();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS