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