Basic Programming C++ Examples

C# Program to Print any input Multiplication table

The Program in C# Program to Print any input Multiplication table is given below:

using System;
namespace MultiplicationTable
{
    class Program
    {
        static void Main(string[] args)
        {
            
            Console.WriteLine("Hello Codeauri Family, Enter the number here to find their multiplication table: ");
            int num = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Okay, the multiplication table of " + num + ":");
            for (int i = 1; i <= 10; i++)
            {
                Console.WriteLine(num + " x " + i + " = " + (num * i));
            }
            Console.ReadLine();
        }
    }
}

Output:

Hello Codeauri Family, Enter the number here to find their multiplication table:
10
Okay, the multiplication table of 10:
10 x 1 = 10
10 x 2 = 20
10 x 3 = 30
10 x 4 = 40
10 x 5 = 50
10 x 6 = 60
10 x 7 = 70
10 x 8 = 80
10 x 9 = 90
10 x 10 = 100

Pro-Tips💡

Here are the step-by-step execution of above program:

  1. using System; is a directive that imports the System namespace, which contains various classes and methods used in the program.
  2. namespace MultiplicationTable defines a namespace that contains all the classes and methods within it.
  3. class Program defines a class that contains the program’s logic.
  4. static void Main(string[] args) is the program’s entry point, which is executed when the program starts.
  5. Console.WriteLine("Hello Codeauri Family, Enter the number here to find their multiplication table: "); prints a prompt asking the user to enter a number.
  6. int num = Convert.ToInt32(Console.ReadLine()); reads the user’s input, converts it from a string to an integer using Convert.ToInt32, and stores the result in the variable num.
  7. Console.WriteLine("Okay, the multiplication table of " + num + ":"); prints a message indicating the number for which the multiplication table will be displayed.
  8. for (int i = 1; i <= 10; i++) is a for loop that will iterate 10 times. i is the loop variable that starts from 1 and increments by 1 each time through the loop.
  9. Console.WriteLine(num + " x " + i + " = " + (num * i)); calculates the product of num and i and prints the result. The line concatenates strings and the product to produce the output.
  10. Console.ReadLine(); waits for the user to press the Enter key before ending the program

Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

Related Posts

Programming Languages( Types, Pros and Cons)-Codeauri

What are the types or levels of Programming Languages? The types or levels of programming languages are divided into two types: Types Of Programming Languages: 1.Machine-level Language :1st…

C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

Leave a Reply

Your email address will not be published. Required fields are marked *

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X