Program to find and display multiplication table of a given number
Program to find and display multiplication table of a given number is discussed here. Given a number, the multiplication table of that number is displayed as output until the end value specified.
Sample input and output format:
Input format:
Input consist of 2 integers.
Sample Input:
1
5
Sample Output:
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
1 * 4 = 4
1 * 5 = 5
Algorithm to display multiplication table of a given number
Input the number for which the multiplication table is to be generated.
Input the end value until which the table has to be generated.
Repeat from i = 1 to end
Display the table values in the given output format.(num * i = num*i)
Program to find and display multiplication table of a given number
C
// C program to display multiplication table of a given number
#include
int main()
{
//fill the code
int num, end;
scanf(“%d”,#);
scanf(“%d”,&end);
int i;
for(i = 1; i <= end; i++)
{
printf(“%d * %d = %d\n”,num, i, num*i);
}
return 0;
}
C++
#include
using namespace std;
int main()
{
//fill the code
int num, end;
cin >> num;
cin >> end;
int i;
for(i = 1; i <= end; i++)
{
cout << num xss=removed>
}
return 0;
}
JAVA 8
// Java program to display multiplication table of a given number
import java.util.*;
public class Main
{
public static void main(String[] args)
{
int num, end;
Scanner sc = new Scanner(System.in);
num = sc.nextInt();
end = sc.nextInt();
int i;
for(i = 1; i <= end; i++)
{
System.out.println(num + ” * ” + i + ” = ” + num*i);
}
}
}
PYTHON 3
# Python program to display multiplication table of a given number
num = int(input())
end = int(input())
for i in range(1, end+1,1):
print(num, “*”, i, “=”, num*i)
OUTPUT
1
5
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
1 * 4 = 4
1 * 5 = 5
Write a public review