Created
December 20, 2013 06:47
-
-
Save itskingori/8051259 to your computer and use it in GitHub Desktop.
Arithmetic Operators and Variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Exercise 02: Arithmetic Operators and Variables</title> | |
</head> | |
<body> | |
<?php | |
// Create the following variables: | |
// $x = 10; | |
// $y = 7; | |
// Write code to print out the following: | |
// 10 + 7 = 17 | |
// 10 - 7 = 3 | |
// 10 * 7 = 70 | |
// 10 / 7 = 1.4285714285714 | |
// 10 % 7 = 3 | |
// Create the variables | |
$x = 10; | |
$y = 7; | |
// Calculate | |
$addition = $x + $y; | |
$subtraction = $x - $y; | |
$multiplication = $x + $y; | |
$division = $x + $y; | |
$modulus = $x % $y; | |
// Output as instructed above | |
echo "10 + 7 = ".$addition.'<br/>'; | |
echo "10 - 7 = ".$subtraction.'<br/>'; | |
echo "10 * 7 = ".$multiplication.'<br/>'; | |
echo "10 / 7 = ".$division.'<br/>'; | |
echo "10 % 7 = ".$modulus.'<br/>'; | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment