using System;

namespace HexMultiplicationTable
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hexadecimal multiplication table.");
            Console.WriteLine();
            for (int i = 1; i <= 16; i++)
            {
                for (int j = 1; j <= 16; j++)
                {
                    if (i == j) Console.BackgroundColor = ConsoleColor.Gray;
                    else Console.BackgroundColor = ConsoleColor.Cyan;
                    Console.Write("{0,4:X}", i * j);
                }
                //go to the next line to start for j loop all over, with i+1 
                Console.WriteLine(); 
            }
            Console.WriteLine();
            Console.WriteLine("The squares of the first 16 numbers:");
            Console.WriteLine();
            for (int j = 1; j <= 16; j++)
            {
                Console.Write("{0,4}", j * j);
            }
            Console.WriteLine();
            Console.WriteLine("**************************************************");
            
            Console.ReadKey();
        }
    }
}
1
Contributor
0
Replies
11
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.