C Program to print multiplication table of a given number

In this C tutorial we will learn how we can print multiplication table of a given number. I’ll help you to understand the concept behind it the logic we gonna use. Then we’ll move forward to write C Program to print multiplication table of a given number.

It is one of the basic program in C generally for the beginners to understand the basic functioning of the C concepts. Where we’re going to take a number from the user and print it’s multiplication table. You all must be well familiar with how Multiplication table look like.

Example :-

Multiplication table of 8 :-

8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80

1. Program outline

In this program first we take input from the user and store it in a variable in C program. we use scanf( ) function to take input from the user. After taking input from the user we run our for loop till 10 by incrementing it by 1 . This all comes in our Calculation part , later we print the concluded output .

2. Concept

The basic understanding you should have before writing C program to print multiplication table of a given number are :-

  • I/O in C
  • Arithmetic operator
  • For loop

Logic to write it’s C program.

  • First take a input from the user and store it in a variable say num.
  • For printing multiplication table we need to Start for loop from 1 to 10 and increment 1 while each iteration.
  • It will look like for( i=1 , i <= 10 , i++ )
  • Finally inside for loop print multiplication table using num * i and print it in required pattern.

Its good if you understood and if not you’ll understand while writing its code . Lets head towards writing its C program.

3. Program

C Program to print multiplication table of a given number:

#include <stdio.h>
int main() {
int num, i;
   
  //Take input from the user
  //Store it in variable num
 
  printf("Enter any positive integer: ");
  scanf("%d", &num);
   
  //start for loop from 1 to 10 
  
   
  for (i = 1; i <= 10; ++i)
   {
    printf("%d * %d = %d \n", 
    num, i, num * i);
  }
  return 0;
}

4. Output

At last we finally reached our conclusion after writing C program , let’s check what output it gives.

C Program to print multiplication table of a given number
groot
groot

Leave a Reply

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