Create a multiplication table using a nested for loop
. The table output should look like this:
Multiplication Table
1 x 1 = 1
1 x 2 = 2
1 x 3 = 3
1 x 4 = 4
1 x 5 = 5
1 x 6 = 6
1 x 7 = 7
1 x 8 = 8
1 x 9 = 9
1 x 10 = 10
and so on...
Get the sum of the numbers in an array by using a foreach loop and for loop.
$numbers = [1, 2, 3, 4, 5]; //sum using foreach loop
$numbers2 = [1, 2, 3, 4, 5,6,7,8,9,19]; //sum using for loop
Sample Output
Sum array using foreach loop
15
Sum array using for loop
64
Calculate the average students grade from an array of students. Each student has their own array with the key grades
.
-
Create an array of students with their names and grades (0 - 100)
john 85, 90, 92, 88
jane 95, 88, 91, 87
joe 75, 82, 79, 88
-
Iterate over the students array with a foreach loop
-
Calculate the average grade for each student.
Sample Output
Average Grade
John: Average Grade = 88.75
Jane: Average Grade = 90.25
Joe: Average Grade = 81