In PHP 1. Type the <!DOCTYPE> declaration, <html> element, header information, a
ID: 3888257 • Letter: I
Question
In PHP
1. Type the <!DOCTYPE> declaration, <html> element, header information, and <body>
element. Use Variables and Arithmetic Operations as the content of the
<title> element.
2. Add the following standard PHP script delimiters to the document body:
<?php
?>
3. Add the following statements to the script section.
a. Assign the integer 20 to a variable named $number_one.
b. Assign the integer 30 to a variable named $number_two.
c. Assign the sum of the values that stored in the variables $number_one and
$number_two to a variable named $addition.
d. Assign the difference of the values that stored in the variables $number_one and
$number_two to a variable named $difference.
e. Assign the product of the values that stored in the variables $number_one and
$number_two to a variable named $product.
f. Assign the division of the values that stored in the variables $number_one and
$number_two to a variable named $division.
g. Assign the remainder of the division of the values stored in the variable $number_one
and $number_two to a variable named $remainder.
h. Write the echo statement to display the following line:
20 + 30 = 50
Note: Do not include the numbers 20, 30, and 50 in the echo
statements. Include the variables whose values are those
numbers ($number_one, $number_two, and $addition.)
i. Write the echo statement to display the following line:
30 – 20 = 10
Again, do not include the numbers 30, 20 and 10 in the echo
statement but rather the variables that store those values.
j. Write the echo statement to display the following line:
20 * 30 = 600
Same as above, Use variable names in the echo statement.
k. Write the echo statement to display the following line:
30 / 20 = 1.5
Same as above, use variable names in the echo statement.
l. Write the echo statement to display the following line:
30 % 20 = 10
Same as above, use variable names.
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<title>Variables and Arithmetic Operations</title>
</head>
<body>
<?php
$number_one = 20; //assigning number_one to 20
$number_two = 30; //assigning number_two to 30
//Performing Arithmetic Operations below
$addition=$number_one+$number_two; //Performing Addition
$difference=$number_two-$number_one; //Performing Substraction
$product=$number_one*$number_two; //Performing Multiplication
$division=$number_two/$number_one; //Performing Division
$remainder=$number_two%$number_one; //Getting Remainder
//Echoing or printing the required statement below
echo "$number_one + $number_two = $addition ";
echo "$number_two - $number_one = $difference ";
echo "$number_one * $number_two = $product ";
echo "$number_two / $number_one = $division ";
echo "$number_two % $number_one = $remainder ";
?>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.