lampPartA5
lampPartA5
Pdf:
PGM-5-6
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Program Five</title>
</head>
<body>
<?php
$noOfLines = "";
$symbol = "";
if (isset($_POST["submit"])) {
$noOfLines = $_POST["line"];
$symbol = $_POST["symbol"];
}
?>
<h2>Pyramid</h2>
<form method="post">
Enter the loop number:
<input type="number" name="line" required value="<?php echo $noOfLines; ?>"><br><br>
Question 5 1
<?php
if ($noOfLines and $symbol) {
for ($i = 0; $i < $noOfLines; $i++) {
echo "<br>";
}
}
?>
</body>
</html>
OR
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Program Five</title>
<?php
$noOfLines = "";
$symbol = "";
if (isset($_POST["submit"])) {
$noOfLines = $_POST["line"];
$symbol = $_POST["symbol"];
}
?>
</head>
<body>
<h2>Pyramid</h2>
<form method="post">
Enter the loop number:
<input type="number" name="line" required value="<?php echo $noOfLines; ?>"><br><br>
<?php
function patternFun($noOfLines, $symbol) {
for ($i = 0; $i < $noOfLines; $i++) {
Question 5 2
for ($j = 0; $j < $i + 1; $j++) {
echo "<b>$symbol</b> ";
}
echo "<br>";
}
}
Output:
Question 5 3