How To Check Table of Number Program.
A table of a number can be print using a loop in the program.
Write a program to print the multiplication table of a number. Given a number n as input, we need to print its table.
We'll print the table of the number is 10.
<?php
$number=10;
for($i=1; $i<=10; $i++){
echo $i*$number;
echo "<br>";
}
?>
Output: 10,20,30,40,50,60,70,80,90,100
Logic: write a program to use a loop to print 1 to 20 table of numbers result will be in separate lines.
<?php
$tableStart=2;
$tableEnd=15;
for($i=$tableStart; $i<=$tableEnd; $i++){
for($j=1; $j<=10; $j++){
echo $i*$j;
if($j<10){
echo ",";
}
}
echo "<br>";
}
?>
Output:
2,4,6,8,10,12,14,16,18,20
3,6,9,12,15,18,21,24,27,30
4,8,12,16,20,24,28,32,36,40
5,10,15,20,25,30,35,40,45,50
6,12,18,24,30,36,42,48,54,60
7,14,21,28,35,42,49,56,63,70
8,16,24,32,40,48,56,64,72,80
9,18,27,36,45,54,63,72,81,90
10,20,30,40,50,60,70,80,90,100
11,22,33,44,55,66,77,88,99,110
12,24,36,48,60,72,84,96,108,120
13,26,39,52,65,78,91,104,117,130
14,28,42,56,70,84,98,112,126,140
15,30,45,60,75,90,105,120,135,150
© 2024 Easy To Learning. All Rights Reserved | Design by Easy To Learning