Advertisement
RahmanIEN

operator aritmatika

Jun 22nd, 2023 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | Source Code | 0 0
  1. <?php
  2. // Penjumlahan
  3. $a = 5;
  4. $b = 3;
  5. $sum = $a + $b;
  6. echo $sum; // Output: 8
  7.  
  8. // Pengurangan
  9. $x = 10;
  10. $y = 4;
  11. $diff = $x - $y;
  12. echo $diff; // Output: 6
  13.  
  14. // Perkalian
  15. $p = 2;
  16. $q = 3;
  17. $product = $p * $q;
  18. echo $product; // Output: 6
  19.  
  20. // Pembagian
  21. $m = 10;
  22. $n = 2;
  23. $division = $m / $n;
  24. echo $division; // Output: 5
  25.  
  26. // Modulus (Sisa Pembagian)
  27. $numerator = 12;
  28. $denominator = 5;
  29. $remainder = $numerator % $denominator;
  30. echo $remainder; // Output: 2
  31.  
  32. // Pangkat
  33. $base = 2;
  34. $exponent = 3;
  35. $power = pow($base, $exponent);
  36. echo $power; // Output: 8
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement