8. WRITE THE PHP PROGRAMS TO DO THE FOLLOWING:
A. IMPLEMENT SIMPLE CALCULATOR OPERATIONS.
B. FIND THE TRANSPOSE OF A MATRIX.
C. MULTIPLICATION OF TWO MATRICES.
D. ADDITION OF TWO MATRICES.
SOLUTION 1 & SOLUTION 2
If xampp is in the system, save the program in C:\xampp\htdocs (start apache in xampp control panel)
If no xampp in the system, save the program in C:\Program Files\Apache Group\Apache2\htdocs & Open Google Chrome & type http://localhost/prog8a.php
prog8a.php
<html>
<head>
<style>
table, td, th {
border: 1px solid black;
width: 35%;
text-align: center;
background-color: lightgray;
}
table { margin: auto; }
input,p { text-align:right; }
</style>
</head>
<body>
<form method="post" action="prog8a.php">
<table>
<caption><h2> SIMPLE CALCULATOR </h2></caption>
<tr>
<td>First Number:</td><td><input type="text" name="num1" /></td>
<td rowspan="2"><button type="submit" name="submit" value="calculate">Calculate</td></tr>
<tr>
<td>Second Number:</td><td><input type="text" name="num2"/></td>
</tr>
</form>
<?php
if(isset($_POST['submit'])) // it checks if the input submit is filled
{
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
if(is_numeric($num1) and is_numeric($num2) )
{
echo "<tr><td> Addition :</td><td><p>".($num1+$num2)."</p></td>";
echo "<tr><td> Subtraction :</td><td><p> ".($num1-$num2)."</p></td>";
echo "<tr><td> Multiplication :</td><td><p>".($num1*$num2)."</p></td>";
echo "<tr><td>Division :</td><td><p> ".($num1/$num2)."</p></td>";
echo "</table>";
}
else
{
echo"<script> alert(' ENTER VALID NUMBER');</script>";
}
}
?>
</body>
</html>
STEPS :( click on image to zoom )
OUTPUT :( click on image to zoom )
A. IMPLEMENT SIMPLE CALCULATOR OPERATIONS.
B. FIND THE TRANSPOSE OF A MATRIX.
C. MULTIPLICATION OF TWO MATRICES.
D. ADDITION OF TWO MATRICES.
SOLUTION 1 & SOLUTION 2
If xampp is in the system, save the program in C:\xampp\htdocs (start apache in xampp control panel)
If no xampp in the system, save the program in C:\Program Files\Apache Group\Apache2\htdocs & Open Google Chrome & type http://localhost/prog8a.php
prog8a.php
<html>
<head>
<style>
table, td, th {
border: 1px solid black;
width: 35%;
text-align: center;
background-color: lightgray;
}
table { margin: auto; }
input,p { text-align:right; }
</style>
</head>
<body>
<form method="post" action="prog8a.php">
<table>
<caption><h2> SIMPLE CALCULATOR </h2></caption>
<tr>
<td>First Number:</td><td><input type="text" name="num1" /></td>
<td rowspan="2"><button type="submit" name="submit" value="calculate">Calculate</td></tr>
<tr>
<td>Second Number:</td><td><input type="text" name="num2"/></td>
</tr>
</form>
<?php
if(isset($_POST['submit'])) // it checks if the input submit is filled
{
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
if(is_numeric($num1) and is_numeric($num2) )
{
echo "<tr><td> Addition :</td><td><p>".($num1+$num2)."</p></td>";
echo "<tr><td> Subtraction :</td><td><p> ".($num1-$num2)."</p></td>";
echo "<tr><td> Multiplication :</td><td><p>".($num1*$num2)."</p></td>";
echo "<tr><td>Division :</td><td><p> ".($num1/$num2)."</p></td>";
echo "</table>";
}
else
{
echo"<script> alert(' ENTER VALID NUMBER');</script>";
}
}
?>
</body>
</html>
STEPS :( click on image to zoom )
OUTPUT :( click on image to zoom )
8b program bro?
ReplyDelete8b Program link - https://vtucselabs.blogspot.com/2019/08/wt8b.html
Delete