C Program to Print Multiplication Table

Programs to print multiplication table in c; In this tutorial, i am going to show you how to write a program to print multiplication table in c program using for loop and while loop.

Algorithm and Programs to Print Multiplication Table in C

  • Algorithm of Print Multiplication Table
  • C Program to Print Multiplication Table using For Loop
  • C Program to Print Multiplication Table using While Loop

Algorithm of Print Multiplication Table

Follow the below given algorithm to write a c program to print multiplication table; as follows:

  • Step 1: Start writing program
  • Step 2: Read the a number from the user.
  • Step 3: Iterate for or while loop.
  • Step 4: Print table of given number. 
  • Step 6:End.

C Program to Print Multiplication Table using For Loop

#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 result of the above c program; as follows:

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

C Program to Print Multiplication Table using While Loop

#include <stdio.h>
int main()
{
   int n, i;
 
    printf("Enter a Number ");
    scanf("%d",&n);
    i=1;
    while(i<=10){
                
        printf("%d * %d = %d \n", n, i, n*i);
        ++i;
    }
     
   return 0;
    
}

The result of the above c program; as follows:

Enter a Number 12
12 * 1 = 12 
12 * 2 = 24 
12 * 3 = 36 
12 * 4 = 48 
12 * 5 = 60 
12 * 6 = 72 
12 * 7 = 84 
12 * 8 = 96 
12 * 9 = 108 
12 * 10 = 120 

Be First to Comment

Leave a Reply

Your email address will not be published.