Jan

# C program to generate multiplication table

- Admin
- 27th Jan, 2023

### Overview:

In this example, you will learn to generate the multiplication table of a number entered by the user up to the given range. Then, I will demonstrate an example of a multiplication table. After all, I will write the logic and **C program to generate a multiplication table** with output.

### Table of contents:

- What is the multiplication table?
- Demonstration of the multiplication table
- Logic to generate multiplication table
- C program to generate multiplication table with output
- Conclusion

### What is a multiplication table?

Multiplication table is a list of multiples of a particular number.

### Demonstration of the multiplication table

### Logic to generate multiplication table

**Step 1:**Input a number from the user to generate multiplication table. Store it in some variable say num.**Step 2:**To print the multiplication table we need to iterate from 1 to 10.**Step 3:**Run a loop from 1 to 10, increment 1 on each iteration.**Step 4:**The loop structure should look like for(i=1; i<=10; i++).**Step 5:**Inside loop generate multiplication table using num * i and print in the specified format.

### C program to generate multiplication table

//Multiplication Table Up to 10 #include <stdio.h> int main() { int n, i; printf("Enter an integer: "); scanf("%d", &n); for (i = 1; i <= 10; ++i) { printf("%d * %d = %d \n", n, i, n * i); } return 0; }

**The output of the Program with code: **

When the above code is executed, it produces the following results:

Enter an integer: 9

9 * 1 = 9

9 * 2 = 18

9 * 3 = 27

9 * 4 = 36

9 * 5 = 45

9 * 6 = 54

9 * 7 = 63

9 * 8 = 72

9 * 9 = 81

9 * 10 = 90

//Multiplication Table Up to a range #include <stdio.h> int main() { int n, i, range; printf("Enter an integer: "); scanf("%d", &n); printf("Enter the range: "); scanf("%d", &range); for (i = 1; i <= range; ++i) { printf("%d * %d = %d \n", n, i, n * i); } return 0; }

When the above code is executed, it produces the following results:

Enter an integer: 12

Enter the range: 8

12 * 1 = 12

12 * 2 = 24

12 * 3 = 36

12 * 4 = 48

12 * 5 = 60

12 * 6 = 72

12 * 7 = 84

12 * 8 = 96

**Conclusion:**

After the successful compilation of the program, In this program, we used two variables num, and i. The variable num is used to store the input integer number and the variable ‘i’ is used to iterate the loop. The product of the number is given by num*i;

#### Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.