Skip to content

Instantly share code, notes, and snippets.

@itskingori
Created December 20, 2013 06:47
Show Gist options
  • Save itskingori/8051259 to your computer and use it in GitHub Desktop.
Save itskingori/8051259 to your computer and use it in GitHub Desktop.
Arithmetic Operators and Variables
<!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