Multiplication Table using Python program

January 04, 2020


              Hello, In this blog we see the Python code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Code:
num = int(input("Display multiplication table of? "))
for i in range(1, 11):
   print(num, 'x', i, '=', num*i)

In the above code we use the range function. So easily we compact the code as compare to c, c++, java. In last print line all the operations are taken in one line and the output is displayed to the user.
Output:

Display multiplication table of? 12
12 x 1 = 12
12 x 2 = 24
12 x 3 = 36
12 x 4 = 48
12 x 5 = 60
12 x 6 = 72
12 x 7 = 84
12 x 8 = 96
12 x 9 = 108
12 x 10 = 120


Multiplication Table using Python program Multiplication Table using Python program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5

Multiplication Table using C++ program

January 04, 2020


C++ program to print Multiplication Table

                    Hello, In this blog we see the c++ program code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Code:
#include<iostream.h>
#include<conio.h>
void main()
{
 int s;
 clrscr();
    cout<<"Enter the number to print the multiplication table: ";
    cin>>s;
    cout<<"\n";
 for(int i=1; i <= 10; i++)
 {
     cout<<s;
     cout<<" * ";
     cout<<i;
     cout<<" = ";
     cout<<s*i;
     cout<<"\n";
 }
getch();
}


         In the above code we use variable 's' to store the input value. And by using for loop the actual multiplication table is displayed.

Output:

Enter the number to print the multiplication table: 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

Multiplication Table using C++ program Multiplication Table using C++ program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5

Multiplication Table using C program

January 04, 2020


C program to print Multiplication Table

                    Hello, In this blog we see the c program code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Code:
#include<stdio.h>
#include<conio.h>
void main()
{
 int s,i,a;
 clrscr();
    printf("Enter the number to print the multiplication table: ");
    scanf("%d",&s);
    printf("\n");
 for(i=1; i <= 10; i++)
 {
     printf("%d",s);
     printf(" * ");
     printf("%d",i);
     a=s*i;
     printf("=%d",a);
     printf("\n");
 }
getch();
}


         In the above code we use variable 's' to store the input value. And by using for loop the actual multiplication table is displayed.

Output:

Enter the number to print the multiplication table: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


Multiplication Table using C program Multiplication Table using C  program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5

Multiplication Table using Java program

January 04, 2020


Java Code to print Multiplication Table

                    Hello, In this blog we see the java code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Program:
import java.util.Scanner;
public class MultiTable1
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
 System.out.print("Enter number:");       
 int n=s.nextInt();
        for(int i=1; i <= 10; i++)
        {
            System.out.println(n+" * "+i+" = "+n*i);
        }
    }
}

                  In the above code we use variable 's' to store the input value. And by using for loop the actual multiplication table is displayed.

Output:






Multiplication Table using Java program Multiplication Table using Java program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5