Problem statement:- Program to print the multiplication table of a given number.
Data requirement:-
Input Data:- num
Output Data:-string output
Output Data:-string output
Program in C
Here is the source code of the C Program to print the multiplication table of a given number.
Code:
#include<stdio.h>
int main()
{
int num,i=0;
printf("Enter a number:");
scanf("%d",&num);
printf("Multiplication Table of %d",num);
for(i=1;i<=10;i++)
{
printf("\n");
printf("%d X %d = %d",num,i,num*i);
}
}
Input/Output:
Enter a number:77
Multiplication Table of 77
77 X 1 = 77
77 X 2 = 154
77 X 3 = 231
77 X 4 = 308
77 X 5 = 385
77 X 6 = 462
77 X 7 = 539
77 X 8 = 616
77 X 9 = 693
77 X 10 = 770
Program in C++
Here is the source code of the C++ Program to print the multiplication table of a given number.
Code:
#include<iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter a number:";
cin>>num;
cout<<"Multiplication Table of "<<num;
for(int i=1;i<=10;i++)
{
cout<<"\n";
cout<<num<<" X "<<i<<" = "<<num*i;
}
}
Input/Output:
Enter a number:32
Multiplication Table of 32
32 X 1 = 32
32 X 2 = 64
32 X 3 = 96
32 X 4 = 128
32 X 5 = 160
32 X 6 = 192
32 X 7 = 224
32 X 8 = 256
32 X 9 = 288
32 X 10 = 320
Program in Java
Here is the source code of the Java Program to print the multiplication table of a given number.
Code:
import java.util.Scanner;
public class MultiplicationTable {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int num;
System.out.println("Enter a number:");
num=cs.nextInt();
System.out.println("Multiplication Table of "+num);
for(int i=1;i<=10;i++)
{
System.out.println();
System.out.print(num+" X "+i+" = "+num*i);
}
cs.close();
}
}
Input/Output:
Enter a number:
25
Multiplication Table of 25
25 X 1 = 25
25 X 2 = 50
25 X 3 = 75
25 X 4 = 100
25 X 5 = 125
25 X 6 = 150
25 X 7 = 175
25 X 8 = 200
25 X 9 = 225
25 X 10 = 250
Program in Python
Here is the source code of the Python Program to print the multiplication table of a given number.
Code:
num=int(input("Enter a number:"))
print("Multiplication Table of",num)
for i in range(1,11):
print(num,"X",i,"=",num*i)
for i in range(1,11):
print(num,"X",i,"=",num*i)
Enter a number:10
Multiplication Table of 10
10 X 1 = 10
10 X 2 = 20
10 X 3 = 30
10 X 4 = 40
10 X 5 = 50
10 X 6 = 60
10 X 7 = 70
10 X 8 = 80
10 X 9 = 90
10 X 10 = 100
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box