Don’t worry, though, because we’ve got you covered. In this article, you’ll learn how to print the multiplication table of a number using Python, C++, JavaScript, and C.

Display Multiplication Table of a Number Up to 10

First, let’s look at how to display multiplication tables for numbers up to 10.

Problem Statement

You’re given a number num. You need to print the multiplication table of num up to 10. Example: Let num = 5. Multiplication table of 5:

Approach to Display the Multiplication Table of a Number Up to 10

You can follow the approach below to display the multiplication table of a number up to 10:

Run a loop from 1 to 10. In each iteration, multiply the given number by iteration no. For example- If the given number is 5, therefore on the 1st iteration, multiply 5 by 1. On the 2nd iteration, multiply 5 by 2, and so on.

C++ Program to Display the Multiplication Table of a Number Up to 10

Below is the C++ program to display the multiplication table of a number up to 10:

Output:

Python Program to Display the Multiplication Table of a Number Up to 10

Below is the Python program to display the multiplication table of a number up to 10:

Output:

JavaScript Program to Display the Multiplication Table of a Number Up to 10

Below is the JavaScript program to display the multiplication table of a number up to 10:

Output:

C Program to Display the Multiplication Table of a Number Up to 10

Below is the C program to display the multiplication table of a number up to 10:

Output:

Display Multiplication Table of a Number Up to a Given Range

Of course, you won’t necessarily stick to multiplication tables that are 10 and below. It pays to know how to do so for higher ones, too, and you’ll find all the information you need below.

Problem Statement

You’re given a number num and a range. You need to print the multiplication table of num up to that range. Example: Let num = 5 and range=14.

Multiplication table of 5 up to range 14:

Approach to Display the Multiplication Table of a Number Up to a Given Range

You can follow the approach below to display the multiplication table of a number up to a given range:

Run a loop from 1 to range. In each iteration, multiply the given number by iteration no. For example- If the given number is 5, therefore on the 1st iteration, multiply 5 by 1. On the 2nd iteration, multiply 5 by 2, and so on.

C++ Program to Display the Multiplication Table of a Number Up to a Given Range

Below is the C++ program to display the multiplication table of a number up to a given range:

Output:

Python Program to Display the Multiplication Table of a Number Up to a Given Range

Below is the Python program to display the multiplication table of a number up to a given range:

Output:

JavaScript Program to Display the Multiplication Table of a Number Up to a Given Range

Below is the JavaScript program to display the multiplication table of a number up to a given range:

Output:

C Program to Display the Multiplication Table of a Number Up to a Given Range

Below is the C program to display the multiplication table of a number up to a given range:

Output:

Understand Basic Programming Principles to Become a Better Programmer

In this article, you learned how to display the multiplication table of a number in few lines of code using the power of loops. In almost every programming language, you can display the multiplication table in few lines of code.

If you want to become a better programmer, you must follow the basic programming principles like KISS (Keep It Simple, Stupid), DRY (Don’t Repeat Yourself), Single Responsibility, YAGNI (You Aren’t Going to Need It), Open/Closed, Composition Over Inheritance, and so on. We’ve got guides on these, so why not head over there next?