# Generate multiplication table of given number

Here given code implementation process.

``````/*
C Program
Generate multiplication table of given number
*/
#include <stdio.h>

//Display tables of a given number
void table_of_number(int number)
{
if (number <= 0)
{
return;
}
int result = 0;
printf("\nNumber %d\n", number);
//display table result from 1 to 10
for (int i = 1; i <= 10; ++i)
{
//Multiply the given number by i value
result = (number * i);
//Display result
printf("%d X %d =  %d\n", number, i, result);
}
}
int main()
{
//Simple Case
table_of_number(7);
table_of_number(5);
table_of_number(11);
return 0;
}``````

#### Output

``````Number 7
7 X 1 =  7
7 X 2 =  14
7 X 3 =  21
7 X 4 =  28
7 X 5 =  35
7 X 6 =  42
7 X 7 =  49
7 X 8 =  56
7 X 9 =  63
7 X 10 =  70

Number 5
5 X 1 =  5
5 X 2 =  10
5 X 3 =  15
5 X 4 =  20
5 X 5 =  25
5 X 6 =  30
5 X 7 =  35
5 X 8 =  40
5 X 9 =  45
5 X 10 =  50

Number 11
11 X 1 =  11
11 X 2 =  22
11 X 3 =  33
11 X 4 =  44
11 X 5 =  55
11 X 6 =  66
11 X 7 =  77
11 X 8 =  88
11 X 9 =  99
11 X 10 =  110``````
``````// Java Program
// Generate multiplication table of given number
class MyMath
{
//Display tables of a given number
public void table_of_number(int number)
{
if (number <= 0)
{
return;
}
int result = 0;
System.out.print("\nNumber " + number + "\n");
//display table result from 1 to 10
for (int i = 1; i <= 10; ++i)
{
//Multiply the given number by i value
result = (number * i);
System.out.print("" + number + " X " + i + " = " + result + "\n");
}
}
public static void main(String[] args)
{
MyMath obj = new MyMath();
//Simple Case
obj.table_of_number(7);
obj.table_of_number(5);
obj.table_of_number(11);
}
}``````

#### Output

``````Number 7
7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70

Number 5
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50

Number 11
11 X 1 = 11
11 X 2 = 22
11 X 3 = 33
11 X 4 = 44
11 X 5 = 55
11 X 6 = 66
11 X 7 = 77
11 X 8 = 88
11 X 9 = 99
11 X 10 = 110``````
``````// C++ Program
// Generate multiplication table of given number
#include<iostream>

using namespace std;
class MyMath
{
public:
//Display tables of a given number
void table_of_number(int number)
{
if (number <= 0)
{
return;
}
int result = 0;
cout << "\nNumber " << number << "\n";
//display table result from 1 to 10
for (int i = 1; i <= 10; ++i)
{
//Multiply the given number by i value
result = (number * i);
cout << "" << number << " X " << i << " = " << result << "\n";
}
}
};
int main()
{
MyMath obj ;
//Simple Case
obj.table_of_number(7);
obj.table_of_number(5);
obj.table_of_number(11);
return 0;
}``````

#### Output

``````Number 7
7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70

Number 5
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50

Number 11
11 X 1 = 11
11 X 2 = 22
11 X 3 = 33
11 X 4 = 44
11 X 5 = 55
11 X 6 = 66
11 X 7 = 77
11 X 8 = 88
11 X 9 = 99
11 X 10 = 110``````
``````// C# Program
// Generate multiplication table of given number
using System;
class MyMath
{
//Display tables of a given number
public void table_of_number(int number)
{
if (number <= 0)
{
return;
}
int result = 0;
Console.Write("\nNumber " + number + "\n");
//display table result from 1 to 10
for (int i = 1; i <= 10; ++i)
{
//Multiply the given number by i value
result = (number * i);
Console.Write("" + number + " X " + i + " = " + result + "\n");
}
}
public static void Main(String[] args)
{
MyMath obj = new MyMath();
//Simple Case
obj.table_of_number(7);
obj.table_of_number(5);
obj.table_of_number(11);
}
}``````

#### Output

``````Number 7
7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70

Number 5
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50

Number 11
11 X 1 = 11
11 X 2 = 22
11 X 3 = 33
11 X 4 = 44
11 X 5 = 55
11 X 6 = 66
11 X 7 = 77
11 X 8 = 88
11 X 9 = 99
11 X 10 = 110``````
``````<?php
// Php Program
// Generate multiplication table of given number
class MyMath
{
//Display tables of a given number
public	function table_of_number(\$number)
{
if (\$number <= 0)
{
return;
}
\$result = 0;
echo "\nNumber ". \$number ."\n";
//display table result from 1 to 10
for (\$i = 1; \$i <= 10; ++\$i)
{
//Multiply the given number by i value
\$result = (\$number * \$i);
echo "". \$number ." X ". \$i ." = ". \$result ."\n";
}
}
}

function main()
{
\$obj = new MyMath();
//Simple Case
\$obj->table_of_number(7);
\$obj->table_of_number(5);
\$obj->table_of_number(11);
}
main();``````

#### Output

``````Number 7
7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70

Number 5
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50

Number 11
11 X 1 = 11
11 X 2 = 22
11 X 3 = 33
11 X 4 = 44
11 X 5 = 55
11 X 6 = 66
11 X 7 = 77
11 X 8 = 88
11 X 9 = 99
11 X 10 = 110``````
``````// Node Js Program
// Generate multiplication table of given number
class MyMath
{
//Display tables of a given number
table_of_number(number)
{
if (number <= 0)
{
return;
}
var result = 0;
process.stdout.write("\nNumber " + number + "\n");
//display table result from 1 to 10
for (var i = 1; i <= 10; ++i)
{
//Multiply the given number by i value
result = (number * i);
process.stdout.write("" + number + " X " + i + " = " + result + "\n");
}
}
}

function main()
{
var obj = new MyMath();
//Simple Case
obj.table_of_number(7);
obj.table_of_number(5);
obj.table_of_number(11);
}
main();``````

#### Output

``````Number 7
7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70

Number 5
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50

Number 11
11 X 1 = 11
11 X 2 = 22
11 X 3 = 33
11 X 4 = 44
11 X 5 = 55
11 X 6 = 66
11 X 7 = 77
11 X 8 = 88
11 X 9 = 99
11 X 10 = 110``````
``````#  Python 3 Program
#  Generate multiplication table of given number
class MyMath :
# Display tables of a given number
def table_of_number(self, number) :
if (number <= 0) :
return

result = 0
i = 1
print("\nNumber ", number ,"\n", end = "")
# display table result from 1 to 10
while (i <= 10) :
# Multiply the given number by i value
result = (number * i)
print("", number ," X ", i ," = ", result ,"\n", end = "")
i += 1

def main() :
obj = MyMath()
# Simple Case
obj.table_of_number(7)
obj.table_of_number(5)
obj.table_of_number(11)

if __name__ == "__main__": main()``````

#### Output

``````Number  7
7  X  1  =  7
7  X  2  =  14
7  X  3  =  21
7  X  4  =  28
7  X  5  =  35
7  X  6  =  42
7  X  7  =  49
7  X  8  =  56
7  X  9  =  63
7  X  10  =  70

Number  5
5  X  1  =  5
5  X  2  =  10
5  X  3  =  15
5  X  4  =  20
5  X  5  =  25
5  X  6  =  30
5  X  7  =  35
5  X  8  =  40
5  X  9  =  45
5  X  10  =  50

Number  11
11  X  1  =  11
11  X  2  =  22
11  X  3  =  33
11  X  4  =  44
11  X  5  =  55
11  X  6  =  66
11  X  7  =  77
11  X  8  =  88
11  X  9  =  99
11  X  10  =  110``````
``````#  Ruby Program
#  Generate multiplication table of given number
class MyMath

# Display tables of a given number
def table_of_number(number)

if (number <= 0)

return
end
result = 0
i = 1
print("\nNumber ", number ,"\n")
# display table result from 1 to 10
while (i <= 10)

# Multiply the given number by i value
result = (number * i)
print("", number ," X ", i ," = ", result ,"\n")
i += 1
end
end
end
def main()

obj = MyMath.new()
# Simple Case
obj.table_of_number(7)
obj.table_of_number(5)
obj.table_of_number(11)
end
main()``````

#### Output

``````Number 7
7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70

Number 5
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50

Number 11
11 X 1 = 11
11 X 2 = 22
11 X 3 = 33
11 X 4 = 44
11 X 5 = 55
11 X 6 = 66
11 X 7 = 77
11 X 8 = 88
11 X 9 = 99
11 X 10 = 110
``````
``````// Scala Program
// Generate multiplication table of given number
class MyMath
{
//Display tables of a given number
def table_of_number(number: Int): Unit = {
if (number <= 0)
{
return;
}
var result: Int = 0;
var i: Int = 1;
print("\nNumber " + number + "\n");
//display table result from 1 to 10
while (i <= 10)
{
//Multiply the given number by i value
result = (number * i);
print("" + number + " X " + i + " = " + result + "\n");
i += 1;
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: MyMath = new MyMath();
//Simple Case
obj.table_of_number(7);
obj.table_of_number(5);
obj.table_of_number(11);
}
}``````

#### Output

``````Number 7
7 X 1 = 7
7 X 2 = 14
7 X 3 = 21
7 X 4 = 28
7 X 5 = 35
7 X 6 = 42
7 X 7 = 49
7 X 8 = 56
7 X 9 = 63
7 X 10 = 70

Number 5
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50

Number 11
11 X 1 = 11
11 X 2 = 22
11 X 3 = 33
11 X 4 = 44
11 X 5 = 55
11 X 6 = 66
11 X 7 = 77
11 X 8 = 88
11 X 9 = 99
11 X 10 = 110``````
``````// Swift Program
// Generate multiplication table of given number
class MyMath
{
//Display tables of a given number
func table_of_number(_ number: Int)
{
if (number <= 0)
{
return;
}
var result: Int = 0;
var i: Int = 1;
print("\nNumber ", number ,"\n", terminator: "");
//display table result from 1 to 10
while (i <= 10)
{
//Multiply the given number by i value
result = (number * i);
print(number ," X ", i ," = ", result ,"\n", terminator: "");
i += 1;
}
}
}
func main()
{
let obj: MyMath = MyMath();
//Simple Case
obj.table_of_number(7);
obj.table_of_number(5);
obj.table_of_number(11);
}
main();``````

#### Output

``````Number  7
7  X  1  =  7
7  X  2  =  14
7  X  3  =  21
7  X  4  =  28
7  X  5  =  35
7  X  6  =  42
7  X  7  =  49
7  X  8  =  56
7  X  9  =  63
7  X  10  =  70

Number  5
5  X  1  =  5
5  X  2  =  10
5  X  3  =  15
5  X  4  =  20
5  X  5  =  25
5  X  6  =  30
5  X  7  =  35
5  X  8  =  40
5  X  9  =  45
5  X  10  =  50

Number  11
11  X  1  =  11
11  X  2  =  22
11  X  3  =  33
11  X  4  =  44
11  X  5  =  55
11  X  6  =  66
11  X  7  =  77
11  X  8  =  88
11  X  9  =  99
11  X  10  =  110``````

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.