Q. Write a program to print multiplication table of a number.

Given a number n as input our task is to print the multiplication table of a number n.

Multiplication Table:- A list of multiples of a particular number, typically from 1 to 10.

For Example:-
Input : 5
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
5 * 9 = 45
5 * 10 = 50
Here we can see our input number is 5 and the ouput is the multiplication table of number 5.

Algorithm

START
Step 1 : Input number num
Step 2 : Loop Start
			for i = 1; i <= 10; ++i
				multiply number with i
				Print the number
		Loop End
STOP


Program To Print Multiplication Table Of A Number

  • C
  • C++
  • Java
  • Python
  • C#
  • PHP
  • #include <stdio.h>
    int main()
    {
        int num = 5;  // Change here to change output
        for (int i = 1; i <= 10; ++i)
            printf("%d * %d = %d\n",num,i,num*i);
            
        
        return 0;
    }
    
    #include <iostream>
    using namespace std;
    int main()
    {
        int num = 5;  // Change here to change output
        for (int i = 1; i <= 10; ++i)
            cout << num << " * " << i << " = " 
                 << num * i << endl;
        
        return 0;
    }
    
    public class LFC
    {
    	public static void main(String[] args) {
    		int num = 5;
             
            for (int i = 1; i <= 10; ++i)
                System.out.println(num + " * " + i +
                                   " = " + num * i);
    	}
    }
    
    
    num = 5
    
    for i in range(1, 11):
       print(num, 'x', i, '=', num*i)
    
    using System;
     
    class LFC
    {
        public static void Main()
        {
            // Change here to
            // change output
            int num = 5;
             
            for (int i = 1; i <= 10; ++i)
                Console.Write(num + " * " + i +
                                  " = " + num *
                                   i + "\n");
        }
    } 
    
    <?php
    $num = 5; 
            
    for ($i = 1; $i <= 10; ++$i)
        echo $num , " * " , $i ,
                  " = " , $num *
                    $i , "\n";
    
    #include <stdio.h>
    int main()
    {
        int num = 5;  // Change here to change output
        for (int i = 1; i <= 10; ++i)
            printf("%d * %d = %d\n",num,i,num*i);
            
        
        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
    5 * 9 = 45
    5 * 10 = 50
    

    Recommended Programs

     Insertion sort program
     Program to check panagram