Program to Display Multiplication Table
Display Multiplication Table in C
In this section, we will learn how to write a C program to display multiplication table in the simplest manner. Multiplication table is not too big of a hurdle but it is commonly asked in various exams which makes it very necessary topic to be learnt and implemented.
Display Multiplication Table
In mathematics, a multiplication table (sometimes, less formally, a times table) is representation of a mathematical table used to determine the multiply arithmetic operation for the given system.
We will learn to write a C program to Display Multiplication Table using simple for loop by defining the range value beforehand so that till the specified range value , multiplication table can be displayed.
Algorithm
- Take the number as input from the user whose table needs to be displayed.
- Declare a variable which will store the product value.
- Start a for loop for multiply and print the multiplication table.
Example 1:
#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; }
Output:
Enter an integer: 7 7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49 7 * 8 = 56 7 * 9 = 63 7 * 10 = 70
Example 2:
#include<stdio.h> void print_table(int range, int num) { int mul; for (int i = 1; i <= range; i++) { mul = num * i; printf("%d * %d = %d", num, i, mul); printf("\n"); } } int main() { int range = 8; int num = 5; print_table(range, num); return 0; }
Output:
5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25 5 * 6 = 30 5 * 7 = 35 5 * 8 = 40
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment