Here, we have a basic program example to display the multiplication table using different languages. This program is created in c language, c++, Java, and Python.
Code to display multiplication table in C language
#include <stdio.h>
void main()
{
int i,n;
printf("Input the number for which the table is to be calculated : ");
scanf("%d",&n);
printf("\n");
for(i=1;i<=10;i++)
{
printf("%d X %d = %d \n",n,i,n*i);
}
}
Code to display multiplication table in C++ language
#include<iostream>
using namespace std;
int main()
{
int i,n;
cout<<"Input the number for which the table is to be calculated : ";
cin>>n;
for(i=1;i<=10;i++)
{
cout<<n<<" X "<<i<<" = "<<n*i<<endl;
}
}
Code to display multiplication table in Python language
n=int(input("Input the number for which the table is to be calculated : \n"))
for i in range(1, 11):
print(i, " X " , n, " = ", i*n)
Code to display multiplication table in Java language
import java.util.*;
public class table {
public static void main(String[] args) {
int i, num;
System.out.println("Input the number for which the table is to be calculated : ");
Scanner s=new Scanner(System.in);
num = s.nextInt();
for(i=1;i<=10;i++)
{
System.out.println(num + " X " + i + " = " + num*i);
}
}
}