BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C Program to Generate Multiplication Table

Last Updated: July 15, 2022 by Chaitanya Singh | Filed Under: C Programs

In this tutorial, you will learn how to write a C program to generate multiplication table. We will see two programs in this article. In the first program, we are printing the multiplication table for the entered number. In the second example, we are displaying the multiplication table upto the specified range.

Example 1: Program to generate multiplication table

In this example, we are using for loop do print the multiplication table. User is asked to enter the integer and then program runs a loop from i= 1 to 10 and for every iteration of the loop, the printf() function prints number * i.

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

Output:
C Program to Generate Multiplication Table

Example 2: Program to display multiplication table till a specified range

In this example, we are not displaying the complete multiplication table. Here we are taking two inputs from the user, the number and the range. The range represents the step till which the table needs to be printed.

In this example, we are also using a do-while loop that checks if the range entered by user is positive. If user enters negative range, this loop prompts the user again to enter the positive range. This loop will keep running and keep prompting user for the correct input until the user enters positive range.

#include <stdio.h>
int main() {
  int number, i, range;
  printf("Enter an integer: ");
  scanf("%d", &number);

  // If user doesn't enter positive range value
  // repeat the prompt.
  do{
    printf("Enter the range: ");
    scanf("%d", &range);
  } while (range <= 0);
  printf("Multiplication table of %d till range %d: \n", number, range);
  for (i = 1; i <= range; ++i) {
    printf("%d * %d = %d \n", number, i, number * i);
  }
  return 0;
}

Output:
C Program to Generate Multiplication Table

Related C Examples:

  • C Program to add two integers
  • C Program to check whether a character is an alphabet or not
  • C Program to check leap year
  • C Program to find the average of two numbers
❮ C TutorialC Programs ❯

Top Related Articles:

  1. C Program to check Armstrong number
  2. C Program to concatenate two strings without using strcat
  3. C Program to find Palindrome numbers in a given range
  4. C program to calculate and print the value of nPr
  5. C Program to read and print employee details using structure

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap